Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to automatically change signature based on recipients in Outlook?

By default, Outlook has a build-in function for users to automatically change signature while sending emails through different email accounts. But beyond that, here I will show you method of automatically changing signature based on different recipients in the To field in Outlook.

Change signature based on recipients automatically with VBA code


Always reply email with the default email account in Outlook:

If you want to always reply email with default email account in your Outlook, the Always reply with default account option of Kutools for Outlook will do you a favor. See screenshot:

Kutools for Outlook: with more than 40 handy Outlook add-ins, free to try with no limitation in 45 days. Download and free trial Now!


Change signature based on recipients automatically with VBA code

Please follow the below steps to apply different signatures to corresponding recipients while sending emails in Outlook.

1. Firstly, you need to disable the auto attached signature feature in Outlook. Please click File > Options to open the Outlook Options window.

2. In the Outlook Options window, select Mail in the left pane, then click the Signatures button in the Compose messages section. See screenshot:

3. In the Signatures and Stationery dialog box, go to the Choose default signature section under the E-mail Signature tab, select an email account in the Email-account drop-down list, and then choose (none) from the New messages and Replies/forwards drop-down lists. Repeat these steps until all email accounts are set to (none). Then click the OK button.

Note: You can also create your needed signatures in this Signatures and Stationery dialog box.

4. Click the OK button when it returns the Outlook Options window.

5. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

6. In the Microsoft Visual Basic for Applications window, double click ThisOutlookSession in the left pane to open the Code window, and the copy below VBA code into the window. See screenshot:

VBA code: Automatically change signature based on recipients in Outlook

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'Updated by ExtendOffice 2019/04/29
Dim xMailItem As MailItem
Dim xRecipients As Recipients
Dim xRecipient As Recipient
Dim xRcpAddress As String
Dim xSignatureFile, xSignaturePath As String
Dim xFSO As Scripting.FileSystemObject
Dim xTextStream As Scripting.TextStream
Dim xSignature As String
On Error Resume Next
Set xFSO = New Scripting.FileSystemObject
If Item.Class <> olMail Then Exit Sub
Set xMailItem = Item
Set xRecipients = xMailItem.Recipients
xSignaturePath = CreateObject("WScript.Shell").SpecialFolders(5) + "\Microsoft\Signatures\"
For Each xRecipient In xRecipients
    xRcpAddress = xRecipient.Address
    Select Case xRcpAddress
        Case "Email Address 1"
            xSignatureFile = xSignaturePath & "aaa.htm"
            Exit For
        Case "Email Address 2", "Email Address 3"
            xSignatureFile = xSignaturePath & "bbb.htm"
            Exit For
        Case "Email Address 4"
            xSignatureFile = xSignaturePath & "ccc.htm"
            Exit For
    End Select
Next
Set xTextStream = xFSO.OpenTextFile(xSignatureFile)
xSignature = xTextStream.ReadAll
xMailItem.HTMLBody = xMailItem.HTMLBody & "" & xSignature & ""
End Sub

Notes:

  • 1). In the VBA code, please replace the “Email Address 1/2/3/4” with the certain email addresses of the recipients.
  • 2). "aaa.htm", "bbb.htm" and "ccc.htm" are the specified signature you will send to corresponding recipients.
  • 3). In this case, signature “aaa” will be sent to “Email Address 1”, signature “bbb” will be sent to “Email Address 2” and “Email Address 3, and “Email Address 4” will receive the email embedded with signature “ccc”. Please change them based on your needs.
  • 4). If there are multiple recipients in an email, the code only works for the first one. And all recipients will receive the email with the same signature specified to that recipient.

7. Then click Tools > References to go to the References-Project dialog box. In the dialog, please check Microsoft Scripting Runtime option, and then click OK button, see screenshot:

8. Press the Alt + Q keys to close the Microsoft Visual Basic for Applications window.

From now on, after composing an email and hitting the Send button, the corresponding signature will be automatically inserted at the end of the email body based on the recipient’s email address in the To field.

If you want to insert timestamp as signature into the email body while creating/replying/forwarding new email in your Outlook, you can enable the Add date signature when create new, reply and forward email option of Kutools for Outlook to acheive it. See screenshot:

Kutools for Outlook: with more than 40 handy Outlook add-ins, free to try with no limitation in 45 days. Download and free trial Now!


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Gregoris Tsintaris · 3 months ago
    Hello! Very nice script, but there is a problem when sending to excahnge addresses, the xRcpAddress returns the X400 name not the smtp address, this makes it impossible to select based on domain. Is there a workaround this?


    Just to improve I have changed the case statement to if using the inStr function to discern mails in bulk

    If InStr(xRcpAddress, "@example") Then
    xSignatureFile = xSignaturePath & "aaa.htm"
    End If
  • To post as a guest, your comment is unpublished.
    Devansh · 6 months ago
    How would this behave if there are multiple recipients?
    • To post as a guest, your comment is unpublished.
      crystal · 5 months ago
      Hi Devansh,
      If there are multiple recipients in an email, the code only works for the first one. And all recipients will receive the email with the same signature specified to that person.
      If you want to incude different signatures when there are multiple recipients, the email should be sent separately to different recipients. And that will need another code to achieve.