Filter Property (Messages Collection)

Filter Property (Messages Collection)

The Filter property returns a MessageFilter object for the Messages collection. Read/write.

Syntax

objMsgColl.Filter

Data Type

Object (MessageFilter)

Remarks

A MessageFilter object with no criteria is created by default for every Messages collection. When you specify criteria by setting properties in the filters Fields collection, the filter restricts any subsequent search on the Messages collection. For more information, see Filtering Messages in a Folder and the MessageFilter Object.

A message filter can also be inherited from the restriction specified in a CDO Rendering TableView object. Writing any property on this filter disinherits it, refreshes the Messages collection, and instantiates a new message filter specifying only the property just written. This new filter, however, is no longer inherited, and the application can read its properties and set additional restrictions within it.

The message filter affects traversals of the Messages collection using the Microsoft® Visual Basic® For Each statement, the Get methods, or the Visual Basic For Next construction. These accesses normally return a Message object but can also return an AppointmentItem object if the collection resides in a calendar folder, a GroupHeader object if the collection is instantiated by a CDO rendering application, or a MeetingItem object if the collection is in an Inbox or Outbox.

Example

This code fragment shows how to set a filtering value in a Messages collections initial default message filter, and then how to clear all settings and reset the filter to its default state of no criteria:

Dim objMsgColl As Messages ' collection
Dim objMessage As Message  ' message passed by filter
Dim objMsgFilt As MessageFilter
' assume valid Messages collection just created
' make first use of filter to check for high importance messages
Set objMsgFilt = objMsgColl.Filter ' original empty default filter
objMsgFilt.Importance = CdoHigh
For Each objMessage in objMsgColl ' loops and Sets each objMessage
    ' process messages that are passed by the filter
Next
' ... later, when current filter settings are no longer needed ...
objMsgColl.Filter = Nothing ' invalidates and clears filter
Set objMsgFilt = objMsgColl.Filter ' new empty filter
' filter now available for new settings
 

See Also

Concepts

Messages Collection Object