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
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 2022/08/01
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 xDoc As Document
Dim xFindStr 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
If xRecipient.AddressEntry.AddressEntryUserType = olExchangeUserAddressEntry Then
xRcpAddress = xRecipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress
Else
xRcpAddress = xRecipient.AddressEntry.Address
End If
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
VBA.DoEvents
Set xDoc = xMailItem.GetInspector.WordEditor
xFindStr = "From: " & xMailItem.Recipients.Item(1).Name & " <" & xRcpAddress & ">"
If VBA.InStr(1, xMailItem.Body, xFindStr) <> 0 Then
xDoc.Application.Selection.HomeKey Unit:=wdStory, Extend:=wdMove
With xDoc.Application.Selection.Find
.ClearFormatting
.Text = xFindStr
.Execute Forward:=True
End With
With xDoc.Application.Selection
.MoveLeft wdCharacter, 2
.InsertParagraphAfter
.MoveDown Unit:=wdLine, Count:=1
End With
Else
With xDoc.Application.Selection
.EndKey Unit:=wdStory, Extend:=wdMove
.InsertParagraphAfter
.MoveDown Unit:=wdLine, Count:=1
End With
End If
xDoc.Application.Selection.InsertFile FileName:=xSignatureFile, Link:=False, Attachment:=False
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 signatures 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 takes the first recipient into consideration. In this case, other recipients will receive the emails with the same signature as the first recipient.
7. Then click Tools > References to go to the References-Project dialog box. In the dialog, please check both the Microsoft Word Object Library and the Microsoft Scripting Runtime options, 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.
Automatically Insert Current Date as Signature When Sending Email In Outlook:
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:
Download and try it now (60-day free trail)
Best Office Productivity Tools
Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook
✔ Email Automation: Auto Reply (Out of Office) / Schedule Send emails / Auto CC/BCC / Advanced Auto Forward / Auto Add Greating ...
✉ Email Management: Easily Recall Emails / Block Scam Emails / Delete Duplicate Emails / 🔎Advanced Search / Consolidate Folders ...
📁 Attachments Pro: Batch Save / Batch Detach / Batch Compress / Auto Save / Auto Detach / Auto Compress ...
🌟 Interface & Interaction Magic: 😊More Pretty and Cool Emojis / Brings Browser Tabs Right Into Your Outlook / Minimize Outlook Instead of Closing ...
👍 One-click Wonders: Reply All with Incoming Attachments / Anti-Phishing Emails / 🕘Show Sender's Time Zone / Send to Recipients Separately ...
👩🏼🤝👩🏻 Contacts & Calendar: Batch Add Contacts From Selected Emails / Split a Contact Group to Individual Groups / Remove Birthday Reminders ...
Over 100 Features Await Your Exploration! Click Here to Discover More.










































