Skip to main content

How to add different signatures to multiple email accounts when create a new email in Outlook?

From the tutorial: Email Signatures In Outlook, you should know how to create a signature in Outlook. However, after creating a new signature, you will have to add the created signature to a new message manually by selecting Signature > The created signature in the message window.

Of course you can have Outlook add a signature automatically when you create a new message by clicking Signature > Signatures, and selecting a signature for a specific email account as shown below.

However, what if you have many email accounts and want to add different signatures for your multiple accounts in batches? In this tutorial, I will introduce a VBA method to help you get this job done easily.


Add different signatures to multiple email accounts when create a new email in Outlook

1. In your Outlook, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, double click on ThisOutlookSession in the Project pane, and copy the below VBA code into the ThisOutlookSession (Code) window. See screenshot:

VBA code: Add different signatures to multiple email accounts when create a new email in Outlook - ThisOutlookSession

Public WithEvents GInspectors As Inspectors
Public WithEvents GExplorer As Explorer

Private Sub Application_Startup()
  Set GInspectors = Application.Inspectors
  Set GExplorer = Application.ActiveExplorer
End Sub

Private Sub GExplorer_InlineResponse(ByVal Item As Object)
‘Update by ExtendOffice
Dim xMail As MailItem
On Error Resume Next
EndTimer
If Item.Class = olMail Then
  Set xMail = Item
  Set GInspector = Nothing
  Set GInspector = xMail.GetInspector
  StartTimer
End If
End Sub

Private Sub GInspectors_NewInspector(ByVal Inspector As Inspector)
  On Error Resume Next
  EndTimer
  Set GInspector = Nothing
  Set GInspector = Inspector
  StartTimer
End Sub

3. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy the following VBA code to the Module window.

VBA code: Add different signatures to multiple email accounts when create a new email in Outlook - Module

Public Declare PtrSafe Function SetTimer Lib "user32" (ByVal HWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As Long
Public Declare PtrSafe Function KillTimer Lib "user32" (ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public GInspector As Inspector

Sub StartTimer()
  On Error Resume Next
  TimerID = SetTimer(0&, 0&, 1000&, AddressOf TimerProc)
End Sub

Sub EndTimer()
  On Error Resume Next
  KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
  On Error Resume Next
  Call SetSignatureToAccount
  EndTimer
End Sub

Sub SetSignatureToAccount()
‘Update by ExtendOffice
Dim xMail As MailItem
Dim xSignatureFile, xSignaturePath As String
Dim xSubject As String
Dim xDoc As Document
Dim xAccount As Account
Dim xIsNew As Boolean
Dim xInspector As Inspector
Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
On Error Resume Next
xSignaturePath = CreateObject("WScript.Shell").SpecialFolders(5) + "\Microsoft\Signatures\"
xSubject = GInspector.Caption
Set xDoc = GInspector.WordEditor
xIsNew = False
Set xMail = GInspector.CurrentItem
Select Case xMail.Parent.Parent
  Case "" 'Replace the email address in double quotes
    If VBA.InStr(xSubject, "RE: ") = 1 Then
      Exit Sub
    ElseIf VBA.InStr(xSubject, "FW: ") = 1 Then
      Exit Sub
    Else
      xSignatureFile = xSignaturePath & "Signature1.htm" 'Replace "Signature1" with your actual signature name
      xIsNew = True
    End If
  Case "" 'Replace the email address in double quotes
    If VBA.InStr(xSubject, "RE: ") Then
      Exit Sub
    ElseIf VBA.InStr(xSubject, "FW: ") Then
      Exit Sub
    Else
      xSignatureFile = xSignaturePath & "Signature2.htm" 'Replace "Signature2" with your actual signature name
      xIsNew = True
    End If
  'Add more Cases for more email accounts
End Select
If xIsNew = True Then
  With xDoc.Application.Selection
    .WholeStory
    .EndKey
    .InsertParagraphAfter
    .MoveDown Unit:=wdLine, Count:=1
    .InsertFile FileName:=xSignatureFile, Link:=False, Attachment:=False
  End With
Else
  With xDoc.Application.Selection
    .MoveRight Unit:=wdCharacter, Count:=1
    .HomeKey Emptyparam, Emptyparam
    .InsertFile FileName:=xSignatureFile, Link:=False, Attachment:=False
  End With
End If
Set xDoc = Nothing
Set GInspector = Nothing
Set xMail = Nothing
End Sub
Note:
  • 1) You should replace the and in the 39th and 48th rows to your actual email addresses.
  • 2) You should replace Signature1 and Signature2 in the 45th and 54th rows to your actual signature names.
  • 3) With the above VBA code, we can add signatures to two email accounts. If you have more accounts, replace the 57th row of the code with more Cases:
  • Case ""
    If VBA.InStr(xSubject, "RE: ") = 1 Then
    Exit Sub
    ElseIf VBA.InStr(xSubject, "FW: ") = 1 Then
    Exit Sub
    Else
    xSignatureFile = xSignaturePath & "Signature.htm"
    xIsNew = True
    End If

4. In the Microsoft Visual Basic for Applications window, click Tools > References, check the box next to Microsoft Word 16.0 Object Library, and click OK.

5. Restart Outlook, and save the VBA codes.

6. Now, when you create a new message with an email account that you have set up a signature for, the corresponding signature will be added automatically.

Note: If you find there are two signatures added when you create a new message with an email account, please click Signature > Signatures in the message window. In the Choose default signature section, select the email account that has two signatures, and choose (none) from the New messages drop-down list.


Related articles

How To Import Or Insert HTML Signatures In Outlook?

For example, you downloaded some HTML signatures from websites, and want to import them in to your Outlook. Any easy ways? This article will guide you to import or insert HTML signatures into Outlook step by step.

How To Insert Background Color Into An Outlook Signature?

It’s easy to add or remove background color in an email in Outlook. But, how could you insert or remove background color in an Outlook signature? Below workarounds will help you solve it:

How To Add Different Signatures To Multiple Email Accounts When Reply Or Forward In Outlook?

If you want Outlook to add signature automatically when you reply to or forward a message, you’ll need to configure the default signature by clicking Signature > Signatures, and selecting a signature for a specific email account as shown below. However, what if you have many email accounts and want to add different signatures for your multiple accounts in batches? In this tutorial, I will introduce a VBA method to help you get this job done easily.

How To Set Different Signatures For Replies And Forwards In Outlook?

Normally, you can set different signatures for different accounts in your Outlook, but, have ever tried to apply different signatures for replies and forwards. It means, when you reply an email, the signature1 is inserted, when you forward an email the signature2 is applied. How could you solve this task in Outlook?


Best Office Productivity Tools

Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook

🤖 AI Mail Assistant: Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...

📧 Email Automation: Out of Office (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

📨 Email Management: Easily Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

📁 Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Boost Your Outlook Productivity with Tabbed Views  /  Minimize Outlook Instead of Closing ...

👍 One-click Wonders: Reply All with Incoming Attachments  /   Anti-Phishing Emails  /  🕘Show Sender's Time Zone ...

👩🏼‍🤝‍👩🏻 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.

Read More       Free Download      Purchase
 

 

Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi,
I tried to initiate this settings in my outlook for changing the signature automatically, but it doesn't function.

the signature stays the same while using different email accounts.

any idea why ?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations