Ask Your Question
3

How can Outlook signature be inserted and Emails be sent out automatically using Excel VBA?

asked 2021-04-26 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-29 02:00:00 +0000

devzero gravatar image

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
edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2021-04-26 11:00:00 +0000

Seen: 10 times

Last updated: Nov 29 '22