PropertyAccessor.SetProperties Method
Outlook Developer Reference |
Sets the properties specified by the array
SchemaNames
to the values specified by the array
Values
.
Version Information
Version Added: Outlook 2007
Syntax
expression.SetProperties(SchemaNames, Values)
expression A variable that represents a PropertyAccessor object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
SchemaNames | Required | Variant | An array of names of properties whose values are to be set as specified by the Values parameter. These properties are referenced by namespace. For more information, see Referencing Properties by Namespace. |
Values | Required | Variant | An array of values that are to be set for the properties specified by the SchemaNames parameter. |
Return Value
A Variant that is Null (Nothing in VBA) if the operation is successful. If there is an error before any properties are set, for example, the number of elements in the SchemaNames array does not match that in the Values array, and an Err value will be returned. If there is an error during the setting of the properties, the return value is an array of Err objects, with the number of elements in this array being the same as that of the SchemaNames array. An Err value in the array is mapped to the error result of setting the corresponding property in the SchemaNames parameter.
Remarks
If the property does not exist and the
SchemaNames
element contains a valid property specifier, then SetProperties creates the property and assigns the property with the value specified by
Values
. The type of the property will be the type of the element passed in
Values
. If the property does exist, then SetProperties assigns the property the value as specified by
Values
.
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
This code sample demonstrates how the SetProperties method sets the values of multiple properties. If a property does not exist, then SetProperties will create the property as long as the parent object supports the creation of those properties. Since the MailItem object supports a MailItem.Save operation, the properties here are saved with an explicit oMail.Save
.
Visual Basic for Applications |
---|
|
See Also