PRB: CDO Filter on AppoinmentItems has Unexpected Behavior
ID: Q192404
|
The information in this article applies to:
-
Collaboration Data Objects (CDO), versions 1.2, 1.21
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.
REFERENCES
For additional information on creating filters for appointments, please see
the following article in the Microsoft Knowledge Base:
Q178508
HOWTO: Write a VB MessageFilter for Your Appointment
Collection
Additional query words:
MAPI_E_TOO_COMPLEX MessageFilter
Keywords : kbCDO120 kbCDO121 kbMsg kbVBp kbGrpMsg
Version : WINDOWS:1.2,1.21
Platform : WINDOWS
Issue type : kbprb