Viewing MAPI Properties

You can use a feature of the CDO Library's Fields collection to view the values of MAPI properties.

The Fields collection's Item property allows you to specify the actual property tag value as an identifier. The MAPI property tag is a 32-bit unsigned integer that contains the property identifier in its high-order 16 bits and the property type (its underlying data type) in the low-order 16 bits.

Note You can only use the MAPI property tag on 32-bit platforms. This method of access is not available on any other platform.

The CDO Library also supports multivalued properties, or properties that represent arrays of values. A multivalued property appears to the Microsoft® Visual Basic® application as a variant array. You can use the For ... Next construction or For Each statement to access individual array entries.

Note Do not mix data types within an OLE variant array that you are going to use with the CDO Library. Unlike variant array members, every member of a MAPI multivalued property must be of the same type. Setting mixed types in a variant array and presenting it to MAPI as a multivalued property results in MAPI errors.

The CDO Library works with three types of message properties:

The Fields collection exposes standard MAPI properties not defined by the CDO Library and custom properties created and named by the application. The Item property selects an individual Field object either by its MAPI property tag or by its custom name.

Although the Field object provides a Delete method, some standard MAPI properties, such as those created by MAPI system components, cannot be deleted.

MAPI stores all properties that represent date and time information using Greenwich Mean Time (GMT). The CDO Library converts these properties so that the values appear to the user in local time.

For definitions and details on all standard MAPI properties, see the MAPI Programmer's Reference.

' Function: Fields_Selector 
' Purpose: View a MAPI property by supplying a property tag value as 
'          the Item value 
' See: Item property (Fields collection) 
Function Fields_Selector() 
Dim lValue As Long 
Dim strMsg As String 
 
On Error GoTo error_olemsg 
 
If objFieldsColl Is Nothing Then 
    MsgBox "Must first select a Fields collection" 
    Exit Function 
End If 
' you can provide a dialog here so users enter MAPI proptags, 
' or select property names from a list; for now, hard-coded value 
lValue = &H001A001E ' VB4.0: lValue = CdoPR_MESSAGE_CLASS 
' &H001A = PR_MESSAGE_CLASS; &H001E = PT_TSTRING 
' high-order 16 bits = property ID, low-order = property type 
Set objOneField = objFieldsColl.Item(lValue) 
If objOneField Is Nothing Then 
    MsgBox "Could not get the Field using the value " & lValue 
    Exit Function 
Else 
    strMsg = "Used the value " & lValue & " to access the property " 
    strMsg = strMsg & "PR_MESSAGE_CLASS: type = " & objOneField.Type 
    strMsg = strMsg & "; value = " & objOneField.Value 
    MsgBox strMsg 
End If 
Exit Function 
 
error_olemsg: 
MsgBox "Error " & Str(Err) & ": " & Error$(Err) 
Resume Next 
 
End Function 
 

See Also

Customizing a Folder or Message