I get tons of OSAT emails and the emails that require actions i want to forward to my store managers. I have filtered in outlook for specific emails to get moved into folders based on teh store numbers inside the body of the email. I could get this script to work for just all emails coming into my inbox from a specific sender but i could not search the email body and forward to spefici people. so i filter first to folders and try change folders in teh script but i cannot get the script to look for emails coming into this folder.
I would also like to delet the email after it has been forwared. Here is the code i have been working with
Public WithEvents objInbox As Outlook.Folder
Public WithEvents objInboxItems As Outlook.Items
Private Sub Application_Startup()
Set objInbox = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
Set objInboxItems = objInbox.Items
End Sub
Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
Dim objMail As Outlook.MailItem
Dim objForward As Outlook.MailItem
If TypeOf Item Is MailItem Then
Set objMail = Item
If (Item.SenderEmailAddress = "Test@gmail.com") And (objMail.Subject = "test") Then
Set objForward = Item.Forward
With objForward
.Subject = "test"
.HTMLBody = "<HTML><BODY> We have successfully tested </BODY></HTML>" & Item.HTMLBody
.Recipients.Add ("test@test.com")
.Recipients.Add ("Test@gmail.com")
.Recipients.ResolveAll
.Importance = olImportanceHigh
.Send
End With
End If
End If
End Sub
question from:
https://stackoverflow.com/questions/65940856/how-to-change-the-folder-in-outlook-script-to-forward-emails 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…