Article ID: 175044
Article Last Modified on 8/18/2005
171440 Where to Acquire the Collaboration Data Objects Library
* AM_MessageFilter.PRG
* --------------------
*
*Create a MAPI Session object then Logon. The Logon dialog can be
*bypassed by providing a valid ProfileName as the first parameter
*(as a string) to the Logon Method as seen below.
objSession = CREATEOBJECT("mapi.session")
objSession.Logon &&objSession.Logon("YourProfileName")
*Instantiate a MessageFilter Object on the Inbox's Messages collection
objMsgColl = objSession.Inbox.Messages
objMsgFilter = objMsgColl.Filter
*Setup the criteria for the MessageFilter
objMsgFilter.Text = "test test"
objMsgFilter.Unread = .T. && Filter for unread messages
*By default the two conditions noted above are logically ANDed, this
*can be changed however to a logical OR instead by uncommenting the
*next line
*objMsgFilter.Or = .T.
*Message filter is now specified; ready for display loop
FOR EACH objMess IN objMsgColl && Operates only on messages post filter
MESSAGEBOX("Message not read: " + objMess.Subject)
NEXT
*Clean up then bail
objSession.Logoff
RELEASE objMessage, objMsgFilter, objMsgColl, objSession
NOTE: If you intend to apply the MessageFilter for only a specific task
then continue processing as normal with the full Messages Collection
available, you MUST be careful and release both the MessageFilter and
refresh the Messages Collection. While this sounds obvious enough when
reading it in print, it is a common mistake when using MessageFilters.
Additional query words: Active Messaging
Keywords: kbhowto kbmsg kbfaq kbcode KB175044