PRB: MAPI_E_TOO_COMPLEX when Sorting the Messages by Subject

ID: Q228890


The information in this article applies to:


SYMPTOMS

When using Collaboration Data Objects to Sort a Messages Collection, the following error message might appear:

[Collaboration Data Objects - MAPI_E_TOO_COMPLEX(80040117)]]


CAUSE

CDO does not support sorting on the MAPI property PR_SUBJECT (represented by the CDO Constant "CdoPR_SUBJECT"). This is documented in CDO 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 Library
    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 Library, please see the following article in the Microsoft Knowledge Base:

Q171440 Where to Acquire the Collaboration Data Objects Libraries

Additional query words: kbCDO110 kbCDO120 kbCDO121 kbMsg kbGrpMsg kbVB


Keywords          : kbCDO110 kbCDO120 kbCDO121 kbMsg kbGrpMsg 
Version           : WINDOWS:1.1,1.2,1.21
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: June 10, 1999