PropertyAccessor.SetProperty Method
Outlook Developer Reference |
Sets the property specified by
SchemaName
to the value specified by
Value
.
Version Information
Version Added: Outlook 2007
Syntax
expression.SetProperty(SchemaName, Value)
expression A variable that represents a PropertyAccessor object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
SchemaName | Required | String | The name of a property whose value is to be set as specified by
Value
. The property is referenced by namespace. For more information, see Referencing Properties by Namespace. |
Value | Required | Variant | The value that is to be set for the property specified by
SchemaName
. |
Remarks
If the property does not exist and the
SchemaName
contains a valid property specifier, then SetProperty creates the property and assigns the value specified by
Value
. If the property does exist and
SchemaName
is valid, then SetProperty assigns the property with the value specified by
Value
.
If the parent object of the PropertyAccessor supports an explicit Save operation, then the properties should be saved to the object with an explicit Save method call. If the object does not support an explicit Save operation, then the properties are saved to the object when SetProperties is called.
Use caution and ensure that all exceptions are handled correctly. Conditions where setting properties fails include:
- The property is read-only, as some Outlook and MAPI properties are read-only.
- The property referenced by the specified namespace is not found.
- The property is specified in an invalid format and cannot be parsed.
- The property does not exist and cannot be created.
- The property exists but is passed a value of an incorrect type.
- Cannot open the property because the client is offline.
For more information on setting properties using the PropertyAccessor object, see Best Practices for Getting and Setting Properties.
Example
The following code sample shows how to use the PropertyAccessor to set a custom property on a MailItem object to a value. If the custom property does not exist, PropertyAccessor.SetProperty will create and then set the property. The property is saved with the MailItem.Save method.
Visual Basic for Applications |
---|
|
See Also