BUG: Accessing Custom Properties using CDO

ID: Q195656

The information in this article applies to:

SYMPTOMS

When you access custom properties with Collaboration Data Objects (CDO), you may receive an error of MAPI_E_NOT_FOUND when you use the third syntax listed in the help for the Fields.Item help:

   objFieldsColl.Item(name [, propsetID] )

CAUSE

This problem is caused by the way in which CDO converts the PropSetID you input from a string to a Global Unique Identifier (GUID). CDO uses the FBinFromHex() function to convert the input string to a binary array and then casts it to a GUID. The GUID structure looks like {ULONG, ULONG, USHORT, char[8]}. When the byte array is cast to this GUID structure, the ULONG and USHORT byte values are in reverse order due to the Little-Endian byte order on x86 architecture machines. The char[] portion is fine because a byte[] array has the same structure as a char[].

RESOLUTION

When inputing the PropSetID, exchange the following positions:

Note: The tables that follow contain a visual representation of the first 16 characters in the string. P1 is position one, P2 represents position two and so forth.

For example, if your GUID is as follows:

   0123456789ABCDEFxxxxxxxxxxxxxxxx

   P1  P2  P3  P4  P5  P6  P7  P8  P9  P10  P11  P12  P13  P14  P15  P16
   --  --  --  --  --- --- --- --- --- ---- ---- ---- ---- ---- ---- ---

   0   1   2   3   4   5   6   7   8   9    A    B    C    D    E    F

For the PropSetID parameter, you need to rearrange and input the GUID as follows:

   67452301AB89EFCDxxxxxxxxxxxxxxxx

   P1  P2  P3  P4  P5  P6  P7  P8  P9  P10  P11  P12  P13  P14  P15  P16
   --  --  --  --  --  --  --  --  --  ---  ---  ---  ---  ---  ---  ---

   6   7   4   5   2   3   0   1   A   B    8    9    E    F    C    D

If your custom property is named "Property" and your GUID is "0123456789ABCDEFxxxxxxxxxxxxxxxx", the code to access the property would be as follows:

   oMessage.oFields.Item("Property", "67452301AB89EFCDxxxxxxxxxxxxxxxx")

If rather than a name, the custom property had an ID of 33026, the ID would need to be converted to hexadecimal and put in the form "0x8102", then use it in the code as in the following example:

   oMessage.oFields.Item("0x8102", "67452301AB89EFCDxxxxxxxxxxxxxxxx")

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

Custom properties are properties that Messaging Application Programming Interface (MAPI) allows you to create by giving a GUID and either a name or number. This allows you to create your own virtual namespace of property identifiers that are unique from those that someone else might create.

REFERENCES

Platform Software Development Kit; search on: "Using Named Properties"

Additional query words:

Keywords          : kbole kbCDO kbCDO100a kbCDO110 kbCDO120 kbCDO121 kbMsg 
Version           : WINDOWS:1.0a,1.1,1.2,1.21
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbnofix

Last Reviewed: November 19, 1998