How to Add Signature in Outlook using Excel VBA – Answer
To add a signature in Outlook using Excel VBA, you can follow the steps below:
- Create a new Outlook MailItem object:
- Set the email properties:
- Create an HTML Signature template:
- Insert the signature into the email body:
- Display the email for review:
- Release the Outlook objects:
Dim olApp As Object
Dim olMail As Object
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
With olMail
.Subject = "Your email subject"
.Body = "Your email body text"
' Add other email properties as needed
End With
Dim signature As String
signature = "Your HTML signature template here"
With olMail
.HTMLBody = .HTMLBody & signature
End With
olMail.Display
Set olMail = Nothing
Set olApp = Nothing
In the code example above, you can replace “Your email subject” and “Your email body text” with the actual subject and body of your email. Additionally, you need to replace “Your HTML signature template here” with the actual HTML content of your signature.