Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
835 views
in Technique[技术] by (71.8m points)

directory - How to change the folder in outlook script to forward emails

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 = "[email protected]") 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 ("[email protected]")
 .Recipients.Add ("[email protected]")
 .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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...