Add signature to your automated emails

Tired of issues connected with email automation in Outlook application? Here is another one! In todays article we are going to get rid of it and learn how to add signature to your automated emails.

If You’ve ever tried to automate your correspondence in Outlook, You probably already did fight with that kind of problem. As far as I remember it was my main, maybe not the only one but main, issue – adding the signature in the end of newly created email using VBA. Now, knowing a few approaches to this topic, I decided to share my knowledge and describe in this article how to add signature to automated emails.

How to add signature in email using VBA?

For todays artcile I prepared 3 ways to do this. Sorted from the easiest to the most complex, but clear, approach.

1. Paste signature from prepared Word doc

This is the easiest way to get this done. In previous article I described how to paste the content of Word document easily, so having signature prepared already in doc file would be very convenient.

The same effect You could get prepared signature inside in code.

2. Create signature from email body

The second option is to get default signature from the email body and put that after the email content. Unfortunately this method has 2 downgrades.

The first disadvantage is that You need to remember to first Display the email and the second is that the final result is probably not that we expect to have.

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

Let Signature = OutMail.Body

With OutMail
    .Body = "Email content" & Signature
End With

3. Get signature from Outlook folder

Finally, the most complex approach is to get the signature from the .htm file, which is located in Outlook directory.

Firstly it finds the directory to the users Signatures folder, then looking for .htm file and as the last step is getting the content of this file into string variable.

Dim S As String
 S = Environ("appdata") & "\Microsoft\Signatures\"
 If Dir(S, vbDirectory) <> vbNullString Then S = S & Dir$(S & "*.htm") Else S = ""
 S = CreateObject("Scripting.FileSystemObject").GetFile(S).OpenAsTextStream(1, -2).ReadAll

The string variable is getting the content of the .htm file – singature with html code. It means that thanks to the method You keep whole formatting of your signature, in contrast to 2nd approach above.

Not the only solution

In this article I showed You 3 different solutions of how to add signature to automated emails using VBA. I hope it will help You in your macros. Choose the best solution for your needs and requirements. Sometimes even the simpliest is enough.

Author: Tomasz Płociński

I'm very advanced in VBA, Excel, also easily linking VBA with other Office applications (e.g. PowerPoint) and external applications (e.g. SAP). I take part also in RPA processes (WebQuery, DataCache, IBM Access Client Solutions) where I can also use my SQL basic skillset. I'm trying now to widen my knowledge into TypeScript/JavaScript direction.

9 thoughts on “Add signature to your automated emails”

  1. Your third option worked like a charm. Been looking for this solution for a long time.

    Thank you!

  2. Option 3 worked for me, however, the signature had pictures that would not show up. I had to edit the Signature HTML file with the full file path opposed to the relative path from the location of the HTM file.

    1. Hi, may you explain to me how you did it in a few steps?
      I’m new to vba and it just won’t display my images in the final mail.

  3. Hi! I have code block for my e mails, Where should I add the third solution on my code block ?

    Sub send_all_mails()

    Dim EApp As Object
    Set EApp = CreateObject(“Outlook.Application”)
    Dim EItem As Object
    On Error Resume Next

    Dim RList As Range
    Set RList = Range(“A2”, Range(“a4”).End(xlDown))

    Dim R As Range
    For Each R In RList

    Set EItem = EApp.CreateItem(0)
    With EItem
    .To = R.Offset(0, 15)
    .CC = “”
    .BCC = “”
    .body = R.Offset(0, 29)

    End With
    Next R

    Set EItem = Nothing
    Set EApp = Nothing

    End Sub

  4. Just wanna say you blew my mind with option 3 – I am currently fixing an issue where I can’t get the pictures to show.
    We’ve been writing emails without nice signatures via VBA for the longest time. This will save us a lot of time.
    Legend among us peasants

Leave a Reply

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