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 20180814
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
    Set xMailItem = Item
    Set xRecipients = xMailItem.Recipients
End If
xSignaturePath = CreateObject("WScript.Shell").SpecialFolders(5) + "\Microsoft\Signatures\"
If xRecipients.Count = 1 Then
    Set xRecipient = xRecipients.Item(1)
    xRcpAddress = xRecipient.Address
    Select Case xRcpAddress
        Case "Email Address 1"
            xSignatureFile = xSignaturePath & "aaa.htm"
        Case "Email Address 2", "Email Address 3"
            xSignatureFile = xSignaturePath & "bbb.htm"
        Case "Email Address 4"
            xSignatureFile = xSignaturePath & "ccc.htm"
    End Select
End If
Set xTextStream = xFSO.OpenTextFile(xSignatureFile)
xSignature = xTextStream.ReadAll
xMailItem.HTMLBody = xMailItem.HTMLBody & "<HTML><BODY><br>" & xSignature & "</br></HTML></BODY>"
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.

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

More than 100 Advanced Functions for Outlook 2010, 2013, 2016, 2019 and 365

screen shot kutools for outlook tiny for banner 201812

More Features  |  Free Download  |  Only $39.00 for hundreds of functions

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.

Be the first to comment.