Solved

Outlook - Remove Disclaimers

Posted on 2009-06-27
14
836 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:mikehudson1
  • 7
  • 6
14 Comments
 
LVL 76

Expert Comment

by:Alan Hardisty
ID: 24728508
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.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24728748
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.
0
 

Author Comment

by:mikehudson1
ID: 24728818
Hi BlueDevilFan : let's say the text simply said "Disclaimer" what would the script need to be to remove it?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24728869
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

    Item.Save

End Sub

Open in new window

0
 

Author Comment

by:mikehudson1
ID: 24728897
Thanks BlueDevil - most helpful. If you are interested in writing something more robust for me I will post a job on elance.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24728936
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?
0
 

Author Comment

by:mikehudson1
ID: 24728963
I'm using Outlook 2003 SP3 with Redemption installed. Thinking about going to Outlook 2007 if it makes things like this easier!
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 76

Expert Comment

by:David Lee
ID: 24728969
I might be able to do it with 2003 but am pretty certain I can do it with 2007.
0
 

Author Comment

by:mikehudson1
ID: 24728974
But you don't have time.....?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24729000
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.
0
 

Author Comment

by:mikehudson1
ID: 24729013
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.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24729321
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

        wrdDoc.UnProtect

    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

            .ClearFormatting

            .Text = varString

            With .Replacement

                .ClearFormatting

                .Text = ""

            End With

            .Execute Replace:=wdReplaceAll, Format:=True, MatchCase:=True, MatchWholeWord:=True

        End With

    Next

    Item.Save

    Set wrdAll = Nothing

    Set wrdDoc = Nothing

    Set olkInspector = Nothing

End Sub

Open in new window

0
 

Author Comment

by:mikehudson1
ID: 24730835
This is really excellent and above the call of duty. Much appreciated. I will test it tomorrow. Have a good Sunday. Best, Mike
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 24731429
Thanks, Mike.  
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
If you don't know how to downgrade, my instructions below should be helpful.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now