Microsoft KB Archive/195656

= BUG: Accessing Custom Properties with CDO (1.x) =

Article ID: 195656

Article Last Modified on 3/4/2004

-

APPLIES TO


 * Microsoft Collaboration Data Objects 1.0a
 * Microsoft Collaboration Data Objects 1.1
 * Microsoft Collaboration Data Objects 1.2
 * Microsoft Collaboration Data Objects 1.21

-



This article was previously published under Q195656



SYMPTOMS
When you access custom properties with Collaboration Data Objects (1.x), 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 (1.x) converts the PropSetID you input from a string to a Global Unique Identifier (GUID). CDO (1.x) 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:
 * 1 and 7
 * 2 and 8
 * 3 and 5
 * 4 and 6
 * 9 and 11
 * 10 and 12
 * 13 and 15
 * 14 and 16

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.

