Regarding to add default signature in vba code for sending mail

AABID QURESHI

New Member
Joined
Dec 6, 2020
Messages
20
Office Version
  1. 2010
Platform
  1. Windows
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.xlsm
ABCDEFG
1ToCCSubjectBodyAttachment1Attachment2Status
2Form - 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.PDFSent
3
4
5
6
7
Send_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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top