Solved

Outlook - Remove Disclaimers

Posted on 2009-06-27
14
859 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
RoboForm Secure Password Management System

RoboForm Everywhere - Superb Browser Support
Windows / Apple / IOS / Android / Linux / Chrome OS
Use different complex passwords everywhere
Best Secure Password Management by far
Synchronize all of your devices instantly
Safe, Secure & Highly Recommended!

 
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
 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Changing a few Outlook Options can help keep you organized!
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

751 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