N
Newt
I'm trying to use the find method to find messages based on the categories
value of the current item. I'm not sure where I'm going wrong. It seems to
get the correct value (strID) from the current item, but I can't figure out
how to write the find method so it references that value. Any help? Thanks.
Sub findmessage(MyMail As Outlook.MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.Items
strID = MyMail.Categories
Set objApp = New Outlook.Application
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
Set objMail = objFolder.Items.find("[Categories] = """ & strID & """")
If objMail Is Nothing Then
MsgBox "nothing"
Else
objMail.Display
End If
End Sub
value of the current item. I'm not sure where I'm going wrong. It seems to
get the correct value (strID) from the current item, but I can't figure out
how to write the find method so it references that value. Any help? Thanks.
Sub findmessage(MyMail As Outlook.MailItem)
Dim strID As String
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objMail As Outlook.Items
strID = MyMail.Categories
Set objApp = New Outlook.Application
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
Set objMail = objFolder.Items.find("[Categories] = """ & strID & """")
If objMail Is Nothing Then
MsgBox "nothing"
Else
objMail.Display
End If
End Sub