-
How move email to another Folder if contains “x” word in subject or body, etc?
Hello,
I'm trying to learn use VBA with Outlook. Simple things in the first place.
I need to adapt this code. I don't get replace "=" by "contains":
("[Subject] = 'alert'")
Doesn't work typing "*" before or an after.
Also I want to add something more... I want moving the email to another Folder names (WORK) If it's contains the "alert" word in the subject OR if contains "check" word in the body...
someone helping me?
Thanks in advance.
Sub MoveItems()
Dim myNameSpace As Outlook.NameSpace
Dim myinbox As Outlook.Folder
Dim myDestFolder As Outlook.Folder
Dim myItems As Outlook.Items
Dim myItem As Object
Set myNameSpace = Application.GetNamespace("MAPI")
Set myinbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myinbox.Items
Set myDestFolder = myinbox.Folders("WORK")
Set myItem = myItems.Find("[Subject] = 'alert'")
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules