Partager via


_PropertyAccessor.SetProperties Method

Sets the properties specified by the array SchemaNames to the values specified by the array Values.

Namespace:  Microsoft.Office.Interop.Outlook
Assembly:  Microsoft.Office.Interop.Outlook (in Microsoft.Office.Interop.Outlook.dll)

Syntax

'Declaration
<DispIdAttribute()> _
Function SetProperties ( _
    SchemaNames As Object, _
    Values As Object _
) As Object
'Usage
Dim instance As _PropertyAccessor
Dim SchemaNames As Object
Dim Values As Object
Dim returnValue As Object

returnValue = instance.SetProperties(SchemaNames, _
    Values)
[DispIdAttribute()]
Object SetProperties(
    Object SchemaNames,
    Object Values
)

Parameters

  • Values
    Type: System.Object

    An array of values that are to be set for the properties specified by the SchemaNames parameter.

Return Value

Type: System.Object
An Object that is Nothing (a null reference (Nothing in Visual Basic) in C#) 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.

Note that a custom property created by using the PropertyAccessor is not supported in a custom view. If you want to view a custom property on an item, create the property by using the Add(String, OlUserPropertyType, Object, Object) method.

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.

  • The property is created using the Add method of the UserProperties object. When setting the property for the first time, you must use the Value property of the UserProperty object, instead of the SetProperties or SetProperty(String, Object) method of the PropertyAccessor object.

For more information on setting properties using the PropertyAccessor object, see Best Practices for Getting and Setting Properties.

See Also

Reference

_PropertyAccessor Interface

_PropertyAccessor Members

Microsoft.Office.Interop.Outlook Namespace