Microsoft KB Archive/192404

= PRB: CDO Filter on AppoinmentItems has Unexpected Behavior =

Article ID: 192404

Article Last Modified on 3/4/2004

-

APPLIES TO


 * Microsoft Collaboration Data Objects 1.2
 * Microsoft Collaboration Data Objects 1.21

-



This article was previously published under Q192404



SYMPTOMS
When filtering on a collection of Collaboration Data Objects (CDO) AppoinmentItems, the Start and End dates must be reversed to make the filter work as expected.

Setting the CdoPR_START_DATE in a MessageFilter on AppointmentItems returns items that start on or before the specified date. Setting the CdoPR_END_DATE returns items that end on or after that date. Attempting to specify other properties to filter on or trying to set one of these properties but not the other results in an error of CDO_E_TOO_COMPLEX.



CAUSE
This is caused by the manner in which the CDO Filter handles the Start and End dates.



RESOLUTION
The solution is to reverse the Start and End dates as shown below: 'You must add a Reference to Microsoft CDO version 1.21. Set objSession = CreateObject("MAPI.Session")

objSession.Logon Set objCalendar = _ objSession.GetDefaultFolder(MAPI.CdoDefaultFolderCalendar) Set oMsgColl = objCalendar.Messages

Set oMsgFilter = oMsgColl.Filter oMsgFilter.Fields.Add CdoPR_START_DATE, "10/1/98" oMsgFilter.Fields.Add CdoPR_END_DATE, "9/1/98"

Set oAppt = oMsgColl.GetFirst MsgBox oAppt.Subject

Do While (Not oAppt Is Nothing) MsgBox oAppt.Subject Set oAppt = oMsgColl.GetNext Loop objSession.Logoff



STATUS
This behavior is by design.

