Removing addresses from forwards and replies RRS feed

  • Question

  • So, my colleague is a bit neurotic and insists that there are no email addresses left in the body of anything we forward or reply to. So I am trying to automate the process where we have to read down the body of all emails and remove all the mailto links and email addresses.

    I am comfortable with VBA code in Excel and Word. But don't really know my way around Outlook. I am hoping to find a way that all addresses can be removed without us having to remember to do it every time.


    Sunday, June 21, 2020 9:03 AM

All replies

  • Hello Michelle,

    It seems you are interested in handling the ItemSend event of the Application class where you may check the message body and remove any email addresses from the body. The HTMLBody property of MailItem returns returns or sets a string representing the HTML body of the specified item. The ItemSend event is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program.

    Public WithEvents myOlApp As Outlook.Application 
    Public Sub Initialize_handler()  
     Set myOlApp = Outlook.Application  
    End Sub 
    Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)  
     Dim prompt As String  
     prompt = "Are you sure you want to send " & Item.Subject & "?"  
     If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then  
     Cancel = True  
     End If  
    End Sub

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Sunday, June 21, 2020 10:56 AM