Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to insert signature into Outlook email when sending by vba in Excel?

When sending email by running VBA code in Excel, the Outlook signature will not be displayed in the email body automatically. This article is talking about sending email with Outlook signature displaying in the email body by VBA code in Excel.

Insert signature into Outlook email when sending by Excel VBA


Easily send email through Outlook based on created mailing list:

The Send Emails utility of Kutools for Excel helps users sending email through Outlook based on created mailing list in Excel. See screen shot:

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

Insert signature into Outlook email when sending by Excel VBA


Supposing you need to send emails to a list of email addresses include the Outlook signature in all sending emails. Please do as follows.

1. Please replace the .Body line in below VBA 2 with the code in VBA 1. And in the VBA 2, move the .Display line up until it locates below the With xMailOut line.

VBA 1: Template of send email with signature in Excel

.HTMLBody = "This is a test email sending in Excel" & "<br>" & .HTMLBody

VBA 2: Send email to email addresses specified in cells in Excel

Sub SendEmailToAddressInCells()
    Dim xRg As Range
    Dim xRgEach As Range
    Dim xRgVal As String
    Dim xAddress As String
    Dim xOutApp As Outlook.Application
    Dim xMailOut As Outlook.MailItem
    On Error Resume Next
    xAddress = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select email address range", "KuTools For Excel", xAddress, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xRg = xRg.SpecialCells(xlCellTypeConstants, xlTextValues)
    For Each xRgEach In xRg
        xRgVal = xRgEach.Value
        If xRgVal Like "?*@?*.?*" Then
            Set xMailOut = xOutApp.CreateItem(olMailItem)
            With xMailOut
                .To = xRgVal
                .Subject = "Test"
                .Body = "Dear " _
                      & vbNewLine & vbNewLine & _
                        "This is a test email " & _
                        "sending in Excel"
                .Display
                '.Send
            End With
        End If
    Next
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

The following screenshot can help you to easily find the differences after changing the VBA code.

After running the VBA code, you can see the default Outlook signature is inserted into the created emails’ body automatically as below screenshot shown.


Related articles:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Jay Kanojiya · 28 days ago
    Thanks to you, I can add signature now but then it removes spaces between paragraph of text. Please Can you Help me ?


    Sub helloworld()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range
    Dim Path As String
    Path = Application.ActiveWorkbook.Path
    Set OutApp = CreateObject("Outlook.Application")

    For Each cell In Range("C4:C6")
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
    .Display
    .To = cell.Value
    .Subject = Cells(cell.Row, "D").Value
    .HTMLBody = "Dear " & Cells(cell.Row, "B").Value & "," _
    & vbNewLine & vbNewLine & _
    "Warm Greetings" _
    & vbNewLine & vbNewLine & _
    "We, JK Overseas, would like to take an opportunity and introduce our company J K Overseas, which is involved in the salt business for the last 3 years. We are currently strong in domestic and expanding overseas. We are the supplier of Edible Salt, Water Softening Salt, De-icing Salt, Industrial Salt" & "." _
    & vbNewLine & vbNewLine & _
    "We have a tie-up with large scale manufacturers in India and procure from them quality Salt and exports. So, we are looking for a reliable expert importer as well as distributor agent to make a long-term Business with mutual benefit" & "." _
    & vbNewLine & vbNewLine & _
    "Please contact us with your requirement or for any other inquiries you may have. We provide reliable logistics and on-time delivery. We are confident that our prices being most competitive will match your expectations" & "." _
    & vbNewLine & vbNewLine & _
    .HTMLBody

    '.Send
    End With
    Next cell
    End Sub
  • To post as a guest, your comment is unpublished.
    fady · 2 months ago
    Dear,
    Can someone help me with my VBA,
    I need the signature in the email created:
  • To post as a guest, your comment is unpublished.
    Bara · 5 months ago
    Hi, I would need help with my macro, I need to insert the Outlook signature under the table, could you help me with that?

    Private Sub CommandButton1_Click()


    Dim outlook As Object
    Dim newEmail As Object
    Dim xInspect As Object
    Dim pageEditor As Object

    Set outlook = CreateObject("Outlook.Application")
    Set newEmail = outlook.CreateItem(0)

    With newEmail
    .To = Sheet5.Range("F1")
    .CC = ""
    .BCC = ""
    .Subject = Sheet5.Range("B5")
    .Body = Sheet5.Range("B41")
    .display

    Set xInspect = newEmail.GetInspector
    Set pageEditor = xInspect.WordEditor

    Sheet5.Range("B6:I7").Copy

    pageEditor.Application.Selection.Start = Len(.Body)
    pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
    pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)

    .display
    Set pageEditor = Nothing
    Set xInspect = Nothing
    End With

    Set newEmail = Nothing
    Set outlook = Nothing

    End Sub
    • To post as a guest, your comment is unpublished.
      crystal · 4 months ago
      Hi Bara,
      Sorry can't help you with that. Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    Kasun · 7 months ago
    Thanks a lot...
  • To post as a guest, your comment is unpublished.
    Prakash · 11 months ago
    Superb!!!!
  • To post as a guest, your comment is unpublished.
    Michael · 1 years ago
    I'm having trouble running this on excel 2016. I get a "Compile Error: User Defined Type Not Defined" message. Please help!
  • To post as a guest, your comment is unpublished.
    Maggie · 1 years ago
    If my body text is linked to pull from excel fields, the use of & .HTMLBody at the end of the string erases all of the body text and just leaves the signature.
  • To post as a guest, your comment is unpublished.
    viraj Shirsat · 1 years ago
    how to add signature if the macro is used by multiple user.
    for eg my macro will be run by 3 other persons as well. So how can the macro use the signature of the user who is running the macro.
    thanks in advance
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good Day,
      The VBA code can automatically recognize the default signature in the Outlook of the sender, and send email with his own signature through Outlook.
  • To post as a guest, your comment is unpublished.
    kostika koruni · 1 years ago
    i am trying to add the outlook signature titled "default" but cannot seem that it works.
    can you please help? I believe that my "xMailout" logic is wrong. this is my suspected faulty area.

    Private Sub CommandButton1_Click()

    Dim xOutApp As Object
    Dim xOutMail As Object
    Dim xMailBody As String
    Dim xMailOut As Outlook.MailItem
    On Error Resume Next
    Set xOutApp = CreateObject("Outlook.Application")
    Set xOutMail = xOutApp.CreateItem(0)
    xMailBody = "Greetings:" & vbNewLine & vbNewLine & _
    "This is line 1" & vbNewLine & _
    "This is line 2" & vbNewLine & _
    "This is line 3" & vbNewLine & _
    "This is line 4"
    On Error Resume Next
    With xOutMail
    .To = "Email.here.com"
    .CC = "Email.here.com"
    .Subject = "Email Title Here - " & Range("Cell#").value
    .Body = xMailBody
    . Attachments.Add ActiveWorkbook.FullName
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    With xMailOut
    .Display
    End With
    ActiveWorkbook.Save
    On Error GoTo 0
    Set xOutMail = Nothing
    Set xOutApp = Nothing
    End Sub
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good day,
      You script has been modified, please have try. Thank you.

      Private Sub CommandButton1_Click()
      Dim xOutApp As Object
      Dim xOutMail As Object
      Dim xMailBody As String
      Dim xMailOut As Outlook.MailItem
      On Error Resume Next
      Set xOutApp = CreateObject("Outlook.Application")
      Set xOutMail = xOutApp.CreateItem(0)
      xMailBody = "Greetings:" & vbNewLine & vbNewLine & _
      "This is line 1" & vbNewLine & _
      "This is line 2" & vbNewLine & _
      "This is line 3" & vbNewLine & _
      "This is line 4"
      On Error Resume Next
      With xOutMail
      .To = "Email.here.com"
      .CC = "Email.here.com"
      .Subject = "Email Title Here - " & Range("Cell#").Value
      .Body = xMailBody
      .Attachments.Add ActiveWorkbook.FullName
      Set xMailOut = xOutApp.CreateItem(olMailItem)
      With xMailOut
      .Display
      End With
      End With
      ActiveWorkbook.Save
      On Error GoTo 0
      Set xOutMail = Nothing
      Set xOutApp = Nothing
      End Sub
  • To post as a guest, your comment is unpublished.
    Chris · 1 years ago
    doesnt work with attachments in Office 2016
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Dear Chris,
      The below VBA code can help you. After running the code, please select cells containing email addresses you will send emails to, and then select the files you need to attach in the email as attachments when the second dialog box pops up. And the default Outlook signature will be displayed in the email body as well. Thank you for your comment.

      Sub SendEmailToAddressInCells()
      Dim xRg As Range
      Dim xRgEach As Range
      Dim xRgVal As String
      Dim xAddress As String
      Dim xOutApp As Outlook.Application
      Dim xMailOut As Outlook.MailItem
      On Error Resume Next
      xAddress = ActiveWindow.RangeSelection.Address
      Set xRg = Application.InputBox("Please select email address range", "KuTools For Excel", xAddress, , , , , 8)
      If xRg Is Nothing Then Exit Sub
      Application.ScreenUpdating = False
      Set xOutApp = CreateObject("Outlook.Application")
      Set xRg = xRg.SpecialCells(xlCellTypeConstants, xlTextValues)
      Set xFileDlg = Application.FileDialog(msoFileDialogFilePicker)
      If xFileDlg.Show = -1 Then
      For Each xRgEach In xRg
      xRgVal = xRgEach.Value
      If xRgVal Like "?*@?*.?*" Then
      Set xMailOut = xOutApp.CreateItem(olMailItem)
      With xMailOut
      .Display
      .To = xRgVal
      .Subject = "Test"
      .HTMLBody = "This is a test email sending in Excel" & "
      " & .HTMLBody
      For Each xFileDlgItem In xFileDlg.SelectedItems
      .Attachments.Add xFileDlgItem
      Next xFileDlgItem
      '.Send
      End With
      End If
      Next
      Set xMailOut = Nothing
      Set xOutApp = Nothing
      Application.ScreenUpdating = True
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    Favio · 2 years ago
    thank u very much, u save my life with this template :D