How to Auto Remove the Email Addresses of Original Sender & Recipients when Forwarding an Outlook Email

When you forward an email in Outlook, the email addresses of the original sender and recipients will be included in message body. At this time, for security, you had better remove these addresses. This post will teach you to let Outlook auto do this.

In many cases, you will need to forward some emails to someone else. By default, the header of the original email will display in the body of forwarding email. And the header will include the email addresses of original sender and recipients. At this point, for security or privacy, you may want to remove these email addresses. Yet, it is too tedious to manually removing them. Therefore, here we’ll guide you to make your Outlook to auto accomplish this task on behalf of you.Auto Remove the Email Addresses of Original Sender & Recipients when Forwarding an Outlook Email

Auto Remove the Email Addresses of Original Sender & Recipients when Forwarding an Email

  1. For a start, launch Outlook.
  2. Then, press “Alt + F11” key buttons to access VBA editor.
  3. Next, copy the following VBA code into the “ThisOutlookSession” project.
Public WithEvents objExplorer As Outlook.Explorer
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objMail As Outlook.MailItem

Private Sub Application_Startup()
    Set objExplorer = Outlook.Application.ActiveExplorer
    Set objInspectors = Outlook.Application.Inspectors
End Sub

Private Sub objExplorer_Activate()
    On Error Resume Next
    If objExplorer.Selection.Item(1).Class = olMail Then
       Set objMail = objExplorer.Selection.Item(1)
    End If
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If Inspector.CurrentItem.Class = olMail Then
       Set objMail = Inspector.CurrentItem
    End If
End Sub

Private Sub objMail_Forward(ByVal Forward As Object, Cancel As Boolean)
    Dim objRegExp As Object
    Dim strHTMLBody As String
 
    Forward.Display
    strHTMLBody = Forward.HTMLBody
 
    'Find email addresses in the body via Regular Expression
    Set objRegExp = CreateObject("vbscript.RegExp")
    With objRegExp
        .Pattern = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
        .IgnoreCase = True
        .Global = True
    End With
 
    'Remove email addresses
    If objRegExp.Test(strHTMLBody) Then
       Set objFoundResults = objRegExp.Execute(strHTMLBody)
       For i = 1 To objFoundResults.Count
           Forward.HTMLBody = Replace(Forward.HTMLBody, objFoundResults.Item(i - 1).Value, "")
       Next
    End If
 
    'Remove useless characters
    Forward.HTMLBody = Replace(Forward.HTMLBody, "[mailto:]", "")
    Forward.HTMLBody = Replace(Forward.HTMLBody, "()", "")
End Sub

Put VBA Code into ThisOutlookSession Project

  1. After that, restart your Outlook program to activate this new macro.
  2. Eventually, you can take a shot:
  • Select or open an email.
  • Then, click the “Forward” button in “Respond” group.Forward Email
  • Lastly, a new forwarding email will display, in which the email addresses of original sender and recipients have been deleted.Email Addresses Auto Removed when Forwarding

Calm Down In Case of Outlook Corruption

When you are subject to any problems in your Outlook, you may get panic, afraid of Outlook corruption. Yet, in honesty, hurry and worry can commonly result in a lot of other issues to your Outlook. Hence, do not panic but keep calm in relevant cases. What’s more, if you’ve kept a robust PST fix tool, like DataNumen Outlook Repair, you can simply employ it to resolve Outlook problems.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix sql and outlook repair software products. For more information visit www.datanumen.com

6 responses to “How to Auto Remove the Email Addresses of Original Sender & Recipients when Forwarding an Outlook Email”

  1. hello, thank you very much for the code! My VBA skills are no more than Alt+F11 and paste; could someone help converting this into a button in an open draft email message that will remove all email addresses from the draft email?

  2. Correction, it does work so forget that
    (but it only works for mail threads that have been “popped out” into a dedicated window).

  3. Correction, it does work so forget that
    (but it only works for mail threads that have been “popped out” into a dedicated window).

Leave a Reply

Your email address will not be published. Required fields are marked *