PRB: MAPI_E_TOO_COMPLEX when Sorting the Messages by Subject (228890)



The information in this article applies to:

  • Collaboration Data Objects (CDO) 1.1
  • Collaboration Data Objects (CDO) 1.2
  • Collaboration Data Objects (CDO) 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:
[Collaboration Data Objects - MAPI_E_TOO_COMPLEX(80040117)]]

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


Modification Type:MinorLast Reviewed:3/4/2004
Keywords:kbMsg kbprb KB228890