How can I build a VBA script that takes an incoming email, modifies its body and forwards it?
How can I build a VBA script that takes an incoming email, modifies its body and forwards it?
I've managed to do the forward part.
Sub ScriptTest(item As Outlook.MailItem)
Dim NewMail As MailItem
Dim obApp As Object
Set obApp = Outlook.Application
Set NewMail = obApp.CreateItem(olMailItem)
With NewMail
.Subject = ""
.To = "
.Body = "REF " & vbCrLf & vbCrLf & "DOM" & vbCrLf & vbCrLf
.Importance = olImportanceHigh
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
NewMail.Send
End Sub
I would like to take an incoming email and paste a specific string after the string I put in the script.
I did a rule then script setup in order to apply the script only with specific incoming mails.
Any help would be wonderful for me.
Work with
MailItem.Forward Method– 0m3r
Sep 4 '18 at 21:57
MailItem.Forward Method
Don't need
obApp within Outlook macro. Modifying the email body can be a lot of work for HTML emails. You need to insert in between the body tag.– PatricK
Sep 4 '18 at 23:55
obApp
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I just learned about NewMailEx event. Apparently, it could be a solution.
– Lispeenium
Sep 4 '18 at 21:05