Hello,
I would like a VBA script that will forward any incoming emails with specific words in the subject.
Example, I wan to to forward emails with 3RE, First Name, Last Name, in the subject.
The problem is that the subject always have the 3RE, first and last names, but in random order. It could be Last, First, 3RE, or frist, last, 3re or have other words between the words.
So far i have this code that I sort of modified, but I am not able to get it to work.
Sub ForwardEmails()
Dim outlookApp
Dim myTasks As Object
Dim outMail As MailItem
Set outlookApp = CreateObject("Outlook.Application")
Set myTasks = outlookApp.ActiveExplorer.Selection
For i = myTasks.Count To 1 Step -1
If TypeOf myTasks(i) Is MailItem Then
If (InStr(1, myTasks(i).Subject, "3RE", vbTextCompare) > 0) And (InStr(1, myTasks(i).Subject, "Devin", vbTextCompare) > 0) And (InStr(1, myTasks(i).Subject, "Jenkings", vbTextCompare) > 0) Then
myTasks(i).Categories = "DvinJenkings"
myTasks(i).Save
Set outMail = myTasks(i).Forward
outMail.Display
outMail.Recipients.Add "someone@someone.com"
End If
End If
Next
End Sub
Bookmarks