Using Message Filters with Task Folders

Recall from Chapter 7 that Messages collections can be filtered using the MessageFilter object. The same technique can be applied to limit the set of tasks returned in a task folder’s Messages collection. Although the MessageFilter object can’t filter on task item-specific properties, such as due date, some of the properties that can be filtered are nevertheless useful when working with tasks. The properties of the MessageFilter object that can be applied to tasks are:

Conversation

Setting the Conversation property causes the associated Messages collection to contain only Message objects having their ConversationTopic properties equal to this value. The datatype is String.

Fields

By adding Field objects to the MessageFilter object’s Fields collection, it is possible to filter on properties that are not directly accessible through the MessageFilter object. For example, this code restricts a Messages collection to items having attachments:

' CdoMessages already Dim'ed and Set.
Dim CdoMessageFilter As MAPI.MessageFilter
Dim CdoFields As MAPI.Fields

Set CdoMessageFilter = CdoMessages.Filter
Set CdoFields = CdoMessageFilter.Fields
CdoFields.Add CdoPR_HASATTACH, True

' At this point, CdoMessages only returns items that have attachments.
Importance

Setting the Importance property causes the associated Messages collection to contain only Message objects having their Importance properties equal to this value. It is a Long that can be set to CdoLow ...

Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.