Home>Templates>Send bulk emails using VBA and Outlook
Send Multiple Mails
Templates VBA

Send bulk emails using VBA and Outlook

In this article, we have create an automation to Send bulk emails using VBA and Outlook on one click. This automation will send the emails using Microsoft Outlook.

Visit our YouTube channel to learn step-by-step video tutorials

Youtube.com/@PKAnExcelExpert

Watch the step by step video tutorial:

How to Send bulk emails using VBA and Outlook?

You need to fill the below given template to send the multiple email.

  • In column “A”, fill “To” email Id.
  • In column “B”, fill the “CC” email id. You can keep it blank, if you don’t want keep anybody in CC.
  • In the column “C”, put the subject of email.
  • In the column “D”, put the mail body content.
  • Column “E” for attachments, Provide the complete path and file name with file extension.  You can keep it blank, if you don’t want to attach file.
  • Column “F” is for status. This is an auto fill column. You don’t need to fill it. Once automation will sent the email it will filled automatically.
Send bulk emails using VBA and Outlook
Send bulk emails using VBA and Outlook

Below is VBA code which we have assigned on “Click to send mails” button.

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 = sh.Range("A" & i).Value
msg.cc = 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
End If

msg.send

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

Next i

MsgBox "All the mails have been sent successfully"

End Sub

 
PK
Meet PK, the founder of PK-AnExcelExpert.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your Excel skills to the next level!
https://www.pk-anexcelexpert.com