PDA

View Full Version : move emails to specific folders based on keywords



Musculito78
07-06-2014, 10:08 PM
hi all

i have some code that i need a bit of help with - what i am trying to do is move emails from my Inbox to other folders based on keywords. The code i have moves an email to a folder called TEST if it contains the keyword ala in the subject line - i would like to know how i can add more keywords to the code (for example search for ala or apa or IES Pty Ltd) here is the code i have:

Sub MovePLA(Item As Outlook.MailItem)
With Item
If InStr(1, LCase(.Subject), "ala ") > 0 Then
Item.Move Session.GetDefaultFolder(olFolderInbox).Folders("TEST")
End If
End With
End Sub

Also is there any way that i can search both the subject and body of the email for those keywords?

Thanks!
Deb

westconn1
07-08-2014, 03:27 AM
i have answered part of this question elsewhere
www.vbforums.com/showthread.php?769855-Outlook-Script-to-search-for-exact-words-in-body-of-an-emaikl



Also is there any way that i can search both the subject and body

change to

if instr(1, lcase(.subject), mys & " ") > 0 or instr(1, lcase(.body), mys & " ") > 0 then

Musculito78
07-08-2014, 05:10 PM
Excellent thank you so much !