1
votes

I am currently in the process of anonymizing emails with vba for a project.

Currently when an email is received I have created a rule which moves the email into a folder, thereafter I run a script using the getlast function, in that specific folder, where I display the newly received email and copy the content of the email and then i paste this into a new email and send to a particular email address. This effectively removes the identifying features of the email.

The final movement to the Rubik's Cube is to find the email signature and replace with blank, in other words delete the signature. I will have the email signatures to do this, however it would be great if someone someone could help with this...

2

2 Answers

3
votes

I found this solution.

'I also had to add Word in tools/references of VBA and then Call DeleteSig(msg) after displaying the item.
'http://www.access-programmers.co.uk/forums/showthread.php?t=259417

Sub DeleteSig(msg As Outlook.MailItem)
    Dim objDoc As Word.Document
    Dim objBkm As Word.Bookmark
    On Error Resume Next
    Set objDoc = msg.GetInspector.WordEditor
    Set objBkm = objDoc.Bookmarks("_MailAutoSig")
    If Not objBkm Is Nothing Then
        objBkm.Select
        objDoc.Windows(1).Selection.Delete
    End If
    Set objDoc = Nothing
    Set objBkm = Nothing
End Sub
2
votes

It's not very hard, but depend on some properties of the mail:

  • Is the mail plain text? or html
  • if HTML, do you have the signature in html format ? (with tags)

I presume you read your mail with a variable of type Outlook.MailItem

' Definition of your mail
Dim OutMail As Outlook.MailItem
dim signature as string
...
with OutMail
    .HTMLBody = Replace(.HTMLBody, signature, "")
End with

If the signature you have is not the exact match, it'll be a little more tricky. I suggest to create a function that detect the signature and return the HTMLBody without it