问题
Our Corporate Exchange admin decided to protect users from phishing by adding a bold red warning in the body of every incoming external email, just in case it might be a phishing attempt. bc MOST of my email is external, this has become obnoxious. I also very often need to manually remove the warning before forwarding or replying email (so as to not alarm the less-savvy recipient). Our corporate admin is not sympathetic to my plight. So, I am looking for a way to automate removing the warning, when email arrive or alternatively when I reply/forward the email. I have played with VB a bit but don’t know enough to write the appropriate code. Any help would be greatly thanked! Using OL 2016 on Windows 10 and warning is in body of message (not subject line)
Edit: Unfortunately OL does not allow macro recording like other office applications. So, I looked at some tutorials that helped but did not explain enough to bring success. I came up with this code but get "Compile error: Invalid attribute in Sub or Function" with the Dim statement highlighted:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim WithEvents myOLMail As Outlook.MailItem
Replace(myOLMail, "Caution - External Email", "") As String
End Sub
It is obvious I need more basic understanding. I read through Getting Started with VBA in Outlook 2010 but need more. Any help or resources would be awesome. I have been wanting to learn VB for some time.
回答1:
In the ThisOutlookSession module.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Item.HTMLBody = Replace(Item.HTMLBody, "Caution - External Email", "")
End Sub
The Dim statement is not needed when using "Application". This is simpler than the way described in Microsoft documentation. If you needed it, it would be outside of the Sub at the top of the module.
来源:https://stackoverflow.com/questions/48652444/automatically-remove-warning-in-email-body