Article ID: 228890
Article Last Modified on 3/4/2004
APPLIES TO
- Microsoft Collaboration Data Objects 1.1
- Microsoft Collaboration Data Objects 1.2
- Microsoft Collaboration Data Objects 1.21
This article was previously published under Q228890
SYMPTOMS
When using Collaboration Data Objects (1.1, 1.2, 1.21) to sort a Messages Collection, an error similar to the following might appear:
CAUSE
CDO (1.1, 1.2, 1.21) does not support sorting on the MAPI property PR_SUBJECT (represented by the CDO (1.1, 1.2, 1.21) Constant "CdoPR_SUBJECT"). This is documented in CDO (1.1, 1.2, 1.21) Help file.
RESOLUTION
In order to sort a Messages Collection by Subject, use the MAPI property PR_NORMALIZED_SUBJECT (Hexadecimal value = &H0E1D001E).
MORE INFORMATION
Here is a code sample that demonstrates how to sort the messages in Inbox based on PR_NORMALIZED_SUBJECT property.
Sub Main()<BR/> 'This code sample requires a reference to the CDO (1.1, 1.2, 1.21) Library 'However if you are using CDO (1.1), you must modify the name of the 'Cdo_PR_NORMALIZED_SUBJECT constant to ActMsgPR_NORMALIZED_SUBJECT ' Dim CDOSession As MAPI.Session 'Object: (MAPI)CDO Session Dim oMsgColl As MAPI.Messages 'Object: MAPI Messages Collection Dim oMsg As MAPI.Message 'Object: MAPI Message Set CDOSession = CreateObject("MAPI.Session") CDOSession.Logon Set oMsgColl = CDOSession.Inbox.Messages oMsgColl.Sort 1, CdoPR_NORMALIZED_SUBJECT 'Next line does same thing 'oMsgColl.Sort 1, &HE1D001E 'Ascending Sort on 'normalized subject Set oMsg = oMsgColl.GetFirst() 'Get the first message While Not oMsg is Nothing Msgbox oMsg.Subject 'Should be in Sorted order Set oMsg = oMsgColl.GetNext Wend End Sub
REFERENCES
For additional information on where to acquire the CDO (all versions) Library, please see the following article in the Microsoft Knowledge Base:
171440 Where to Acquire the Collaboration Data Objects Libraries
Keywords: kbmsg kbprb KB228890