• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Remove text to Clean Up

jomili

New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2010
#1
I get hundreds of emails per day, many of them back and forth between groups of people. so I frequently use Outlook 2013's Clean Up tool to wipe out all the individual emails and just keep the gist of the conversation. However, our IT department has just added a wrinkle that I can't find a way around.

Many of the emails come from people outside my organization. For each of those letters our IT department is adding a red-bordered box surrounding red text which reads "WARNING: This email is from outside the Company system. Do not click on links or attachments unless you expect them from the sender and know the content is safe."

So now, when there are back and forth emails, some of the replies have this message in each letter, some have it in only 1 or letters in the chain, etc. So, the Clean Up tool looks at these as different conversations and won't clean them up.

I'd like a way to automatically strip out that text when the email comes in. I tried using the code below, which works on an open email, but it fell far short of what I need. The email was in HTML and after running the code all pictures and content were replaced by URL. Also, I'd rather have something that could strip it out when the letter comes in rather, than trying to clean each one by hand. I'm comfortable with VBA for Excel, not very familiar with VBA for Outlook, so 'd appreciate any help I could get.
Code:
Sub RemoveExpression()

Dim Insp As Inspector
Dim obj As Object

    Set Insp = Application.ActiveInspector
    Set obj = Insp.CurrentItem

    obj.Body = Replace(obj.Body, "WARNING: This email is from outside the Company system. Do not click on links or attachments unless you expect them from the sender and know the content is safe.", "")

    Set obj = Nothing
    Set Insp = Nothing
    
End Sub
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#2
You need to use a run a script rule and use htmlbody. obj.htmlBody = Replace(obj.htmlBody
if you get both html and plain text, you'll need to test for the format and use either obj.body or obj.htmlbody

See Outlook's Rules and Alerts: Run a Script for more information and links to additional samples. .