# Regarding to add default signature in vba code for sending mail



## AABID QURESHI (Jul 25, 2022)

Dear Sir,
I have a format for sending multiple mails with the help of excel.
I need your help to create a code to add the default signature in vba code.

Send Multiple Mails.xlsmABCDEFG1ToCCSubjectBodyAttachment1Attachment2Status2Form - 16C:\Users\aabid.q\Desktop\FORM 16 - Copy\GURM_PART_A\10000015_AITPM6356J_2021-22.pdfC:\Users\aabid.q\Desktop\FORM 16 - Copy\GURM_PART_B\10000015_AITPM6356J_PARTB_2021-22.PDFSent34567Send_Mails

below are the codes.

Option Explicit

Sub Send_Mails()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Send_Mails")
Dim i As Integer

Dim OA As Object
Dim msg As Object

Set OA = CreateObject("outlook.application")

Dim last_row As Integer
last_row = Application.CountA(sh.Range("A:A"))

For i = 2 To last_row
    Set msg = OA.createitem(0)
    msg.to = Replace(sh.Range("A" & i).Value, ",", ";")
    msg.cc = Replace(sh.Range("B" & i).Value, ",", ";")
    msg.Subject = sh.Range("C" & i).Value
    msg.body = sh.Range("D" & i).Value

    If sh.Range("E" & i).Value <> "" Then
        msg.attachments.Add sh.Range("E" & i).Value
        msg.attachments.Add sh.Range("F" & i).Value
    End If

    msg.send

    sh.Range("G" & i).Value = "Sent"

Next i

MsgBox "All the mails have been sent successfully"


End Sub


----------



## Amir Wisal (Dec 29, 2022)

Hi Abid,

add a variable like Dim sig As String and try changing this part only.

Set msg = OA.createitem(0)
With msg
.to = Replace(sh.Range("A" & i).Value, ",", ";")
.cc = Replace(sh.Range("B" & i).Value, ",", ";")
.Subject = sh.Range("C" & i).Value
.display
.HTMLBody= sh.Range("D" & i).Value & .HTMLBody

End with

also remove this argument "msg.send"

For reference, see this thread VBA Outlook Email with Signature


----------

