Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
912 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 = "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

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...