Automatically Remove Warning in Email Body

我是研究僧i 提交于 2020-02-23 07:47:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!