By default, a calendar folder’s Messages collection contains all of the user’s appointments. In most applications, it’s desirable to cut this down to just the appointments that fall within a certain date or time range (for example, when the application is displaying the current day’s or week’s appointments). This can be achieved with the MessageFilter object, available through the Messages collection’s Filter property.
MessageFilter object was introduced in Chapter 7,
and it’s used here in much the same way. However, when using
the MessageFilter object to filter appointments, only the start time
and end time can be filtered. If an attempt is made to filter other
error is raised. Further, the MessageFilter object doesn’t have
explicit properties for filtering the start time and end time, so the
Fields collection must be used to achieve this result. The Fields
collection provides a way to access MAPI properties that aren’t
otherwise exposed by CDO. The Fields collection is examined in detail
in Chapter 9, where it allows us to access task
information. (CDO objects don’t have any properties that expose
task information.) For the present discussion it will suffice to note
that the start and end date properties of the MessageFilter object
can be set with the following code, which is taken from Example 8-1, to be shown shortly:
Set CdoFields = CdoMessageFilter.Fields Set CdoField = CdoFields.Add(CdoPR_START_DATE, ...