Platform SDK: Exchange Server |
The CommentCondition COM class is a collection (of PropVal objects) that defines an object with methods and properties that you can use to create a comment condition.
Use the CommentCondition object to create a condition that associates one or more PropVal objects with another condition.
The following example creates a condition that identifies messages sent from the personal address book entry Spammer. It shows how to save the sender's entry ID in a Comment condition, in case you later want to display further information about the sender in your script.
const CdoAddressListPAB = 1 ' Personal address book const CdoPR_SENDER_ENTRYID = &H0C190102 const CdoPR_SEARCH_KEY = &H300B0102 const CdoPR_SENDER_SEARCH_KEY = &H0C1D0102 const REL_EQ = 7 Set objSession = CreateObject("MAPI.Session") objSession.Logon "","",False,True,True,True,"SERVER" & vbLF & "TestUser" Set objRules = CreateObject("MSExchange.Rules") objRules.Folder = objSession.Inbox Set objPAB = objSession.GetAddressList(CdoAddressListPAB) Set objPABEntries = objPAB.AddressEntries For Each objFromAddress In objPABEntries If objFromAddress.Name = "Spammer" Then SenderSearchKey = objFromAddress.Fields(CdoPR_SEARCH_KEY) Exit For End If Next Set objIDPropVal = CreateObject("MSExchange.PropertyValue") objIDPropVal.Tag = CdoPR_SENDER_ENTRYID objIDPropVal.Value = objFromAddress.ID Set objSearchPropVal = CreateObject("MSExchange.PropertyValue") objSearchPropVal.Tag = CdoPR_SENDER_SEARCH_KEY objSearchPropVal.Value = SenderSearchKey Set objPropCond = CreateObject("MSExchange.PropertyCondition") objPropCond.Value = objSearchPropVal objPropCond.Operator = REL_EQ objPropCond.PropertyTag = CdoPR_SENDER_SEARCH_KEY Set objCmtCond = CreateObject("MSExchange.CommentCondition") objCmtCond.Condition = objPropCond objCmtCond.Add objIDPropVal ...