Partager via


_PropertyAccessor.SetProperty Method

Sets the property specified by SchemaName to the value specified by Value.

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

Syntax

'Declaration
<DispIdAttribute()> _
Sub SetProperty ( _
    SchemaName As String, _
    Value As Object _
)
'Usage
Dim instance As _PropertyAccessor
Dim SchemaName As String
Dim Value As Object

instance.SetProperty(SchemaName, Value)
[DispIdAttribute()]
void SetProperty(
    string SchemaName,
    Object Value
)

Parameters

  • Value
    Type: System.Object

    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.

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(Object, Object) or SetProperty 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