Muokkaa

Jaa


PropertyAccessor.GetProperty method (Outlook)

Returns an Object that represents the value of the property specified by SchemaName.

Syntax

expression. GetProperty( _SchemaName_ )

expression A variable that represents a PropertyAccessor object.

Parameters

Name Required/Optional Data type Description
SchemaName Required String The name of the property whose value is to be returned. The property is referenced by namespace. For more information, see Referencing Properties by Namespace.

Return value

A Variant value that represents the value of the requested property as specified by SchemaName.

Remarks

The type of the return value will be the same as the type of the underlying property. Certain raw property types such as PT_OBJECT are unsupported and will raise an error. If you require conversion of the raw property type, for example, from PT_BINARY to a string, or from PT_SYSTIME to a local time, use the helper methods PropertyAccessor.BinaryToString and PropertyAccessor.UTCToLocalTime.

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

Example

The following code sample demonstrates how to use the GetProperty method to read a MAPI property that belongs to a MailItem but which is not exposed in the Outlook object model, PR_TRANSPORT_MESSAGE_HEADERS.

Sub DemoPropertyAccessorGetProperty() 
 Dim PropName, Header As String 
 Dim oMail As Object 
 Dim oPA As Outlook.PropertyAccessor 
 'Get first item in the inbox 
 Set oMail = _ 
 Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
 'PR_TRANSPORT_MESSAGE_HEADERS 
 PropName = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
 'Obtain an instance of PropertyAccessor class 
 Set oPA = oMail.PropertyAccessor 
 'Call GetProperty 
 Header = oPA.GetProperty(PropName) 
 Debug.Print (Header) 
End Sub

See also

PropertyAccessor Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.