To insert an Outlook signature in an email using Excel VBA, you can use the following code:
Sub AddOutlookSignature()
Dim Signature As String
Dim OutlookApp As Outlook.Application
Dim Mail As Outlook.MailItem
Set OutlookApp = New Outlook.Application
Set Mail = OutlookApp.CreateItem(olMailItem)
Signature = OutlookApp.EmailSignature
With Mail
.Display
.HTMLBody = Signature
End With
Set Mail = Nothing
Set OutlookApp = Nothing
End Sub
To send out an email automatically using Excel VBA, you can use the following code:
Sub SendEmail()
Dim OutlookApp As Outlook.Application
Dim Mail As Outlook.MailItem
Set OutlookApp = New Outlook.Application
Set Mail = OutlookApp.CreateItem(olMailItem)
With Mail
.To = "recipientemailaddress@example.com"
.Subject = "Email subject"
.Body = "Email body"
.Send
End With
Set Mail = Nothing
Set OutlookApp = Nothing
End Sub
You can combine these two codes to insert the Outlook signature and send out the email automatically using Excel VBA as follows:
Sub SendEmailWithSignature()
Dim Signature As String
Dim OutlookApp As Outlook.Application
Dim Mail As Outlook.MailItem
Set OutlookApp = New Outlook.Application
Set Mail = OutlookApp.CreateItem(olMailItem)
Signature = OutlookApp.EmailSignature
With Mail
.To = "recipientemailaddress@example.com"
.Subject = "Email subject"
.HTMLBody = Signature & "Email body"
.Send
End With
Set Mail = Nothing
Set OutlookApp = Nothing
End Sub
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-04-26 11:00:00 +0000
Seen: 10 times
Last updated: Nov 29 '22
How can padding be added to an HTML email signature in Outlook?
Why does Metamask require a password for every transaction signature request?
What is the signature of the setContentView() function?
How can the parent window of a UserForm be modified using VBA?
What is the method of incorporating a dynamic VLOOKUP into FormulaR1C1 using VBA?
What are the steps to creating an 'If Then' Loop using vba?
How can you switch from one opened Excel application to another using VBA?
How can I assess a formula from a different cell without using the equal (=) sign or VBA?