Outlook - Remove Disclaimers

Does anyone know of an Outlook add-in which automatically removes disclaimers (or other annoying repetitive text) from emails coming into Outlook? I want to remove the text at the bottom of all in bound emails. This must be done in the Outlook client. The add-in would obviously need to be told which text it should look for and strip out. Thanks, Mike
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alan HardistyCo-OwnerCommented:
I would be extremely surprised if there was any software to do this as it would be difficult to get the software right so that it can pick up the correct information and leave the message intact.
Sure it is annoying scrolling through yards of repeated rubbish but imagine what would happen if it got it wrong and started to delete part of the message.  What could you do to undo it?
Doing a quick Google does not bring anything useful up, so I doubt you will find anything, but good luck.
David LeeCommented:
Hi, mikehudson1.

If the disclaimer text is always the same, then I can accomplish this with a script and a rule.  If the text varies, then it's still possible but every variation increases the work the script will have to perform on every message it receives.
mikehudson1Author Commented:
Hi BlueDevilFan : let's say the text simply said "Disclaimer" what would the script need to be to remove it?
Ensure Business Longevity with As-A-Service

Using the as-a-service approach for your business model allows you to grow your revenue stream with new practice areas, without forcing you to part ways with existing clients just because they don’t fit the mold of your new service offerings.

David LeeCommented:
Something like this will do it.  The problem with removing a disclaimer text is that there's no means of specifying context (i.e. confining removal to just the disclaimer).  Outlook has no means of separating the disclaimer from the rest of the message.  From its perspective the disclaimer text is just part of the message.  The code below would remove the word "Disclaimer" wherever it appeared in the message.  The longer and more unique the disclaimer is the less likely the code is to remove anything else.  For HTML messages though there is another problem.  The disclaimer may use bold or italics or font changes that add tags to the text.  For example, lets say the disclaimer reads "Disclaimer: The contents of the message is meant only for the person it is addressed to."  To eliminate it you change the code like this

Item.HTMLBody = Replace(Item.HTMLBody, "Disclaimer: The contents of the message is meant only for the person it is addressed to.", "")

This will work fine so long as the author didn't apply any formatting to the text.  However, if they bolded the word "only", then the actual text would read

Disclaimer: The contents of the message is meant <b>only</b> for the person it is addressed to.

The code would not remove the text because it doesn't match.  
Sub RemoveDisclaimer(Item As Outlook.MailItem)
    Select Case Item.BodyFormat
        Case olFormatHTML
            Item.HTMLBody = Replace(Item.HTMLBody, "Disclaimer", "")
        Case Else
            Item.Body = Replace(Item.Body, "Disclaimer", "")
    End Select
End Sub

Open in new window

mikehudson1Author Commented:
Thanks BlueDevil - most helpful. If you are interested in writing something more robust for me I will post a job on elance.
David LeeCommented:
I appreciate the offer.  Unfortunately I don't have the time.  There might be another approach that's not too complicated.  What version of Outlook are you using?
mikehudson1Author Commented:
I'm using Outlook 2003 SP3 with Redemption installed. Thinking about going to Outlook 2007 if it makes things like this easier!
David LeeCommented:
I might be able to do it with 2003 but am pretty certain I can do it with 2007.
mikehudson1Author Commented:
But you don't have time.....?
David LeeCommented:
LOL.  I don't have time to take projects on elance or develop add-ins.  I do have time to answer questions here on EE and develop simple solutions (not add-ins) to questions.  Using 2007's Word integration I'm pretty confident I can do this with under 50 lines of code.  I couldn't do all the declarations and subroutine names in an add-in in that many lines.  Plus for an add-in I'd have to use the full version of VB which increases the testing time.  In contrast it's easy to test VBA in Outlook's integrated VB environment.  Add-ins are also more likely to have problems requiring more debugging.
mikehudson1Author Commented:
OK - understood. If you can do it in 50 lines in '07 on EE that would be great although if that's too big an ask I understand. I have a dinner now so must step away for the evening. Cheers, Mike.
David LeeCommented:
These 32 lines should do it.  Follow these instructions to use this.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10. Create a rule that fires for all messages
11. Set the rule's action to "run a script" and select this script as the one to run

The text you want to remove is defined by the AT (for annoying text) constants at the top of the procedure.  Each constant defines one string of text that you want removed.  You can have as many of them as you want and each one can be as long as you need it to be.  If you add or remove constants, then be sure to edit line 15.  It builds an array of strings.  

The strings are processed sequentially from first to last, so be mindful fo the order you put them in.  Consider a situation where you've defined them like this

    Const AT01 = "Disclaimer"
    Const AT02 = "Legal Disclaimer: This message is intended ..."

The string represented by AT02 will never be found because processing AT01 will remove all occurrences of "Disclaimer" making it impossible to find "Legal Disclaimer".  Also keep in mind that there is no concept of context, so the process will remove all occurrences of any string you define, not just those that appear in a disclaimer.

This is intended for Outlook 2007.  It may work in Outlook 2003, but I have not tested it with that version.
Sub RemoveDisclaimer2(Item As Outlook.MailItem)
    'Add/remove annoying text constants as needed.  Each constant defines one string of text that you find annoying and want removed.'
    Const AT01 = "Legal Disclaimer: This message is intended ..."
    Const AT02 = "Thought for the day"
    Const AT03 = "Some other annoying text"
    Const wdReplaceAll = 2
    Const wdAllowOnlyReading = 3
    Dim olkInspector As Outlook.Inspector, wrdDoc As Object, wrdAll As Object, arrTTR As Variant, varString As Variant
    Set olkInspector = Application.Inspectors.Add(Item)
    Set wrdDoc = olkInspector.WordEditor
    If wrdDoc.ProtectionType = wdAllowOnlyReading Then
    End If
    'Edit this line as needed.  Include all the annoying test constants defined at the top of the procedure'
    arrTTR = Array(AT01, AT02, AT03)
    For Each varString In arrTTR
        Set wrdAll = wrdDoc.Range(Start:=0, End:=0)
        With wrdAll.Find
            .Text = varString
            With .Replacement
                .Text = ""
            End With
            .Execute Replace:=wdReplaceAll, Format:=True, MatchCase:=True, MatchWholeWord:=True
        End With
    Set wrdAll = Nothing
    Set wrdDoc = Nothing
    Set olkInspector = Nothing
End Sub

Open in new window

mikehudson1Author Commented:
This is really excellent and above the call of duty. Much appreciated. I will test it tomorrow. Have a good Sunday. Best, Mike
David LeeCommented:
Thanks, Mike.  

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.