Sending Emails to a List of People Using VBA in Excel

Automating the process of sending emails to a list of recipients can save time and effort. With VBA (Visual Basic for Applications) in Excel, you can easily create a script to send personalized emails to multiple people. In this article, we’ll explore how to send emails using VBA in Excel, providing a step-by-step guide and a code example to help you streamline your email communication process.

Step 1: Set up the Email List : Create a worksheet in Excel with columns for the recipient’s email address, subject, and body of the email. Populate the rows with the relevant information for each recipient.

Step 2: Access the VBA Editor in Excel : Open Excel and navigate to the workbook where you want to send the emails. Press “Alt+F11” to access the VBA editor.

Step 3: Write the VBA Code: Below is an example of VBA code that demonstrates how to send emails to a list of people:

Sub SendEmails()
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim MailRange As Range
Dim Recipient As String
Dim Subject As String
Dim Body As String

‘ Set up the Outlook application
Set OutlookApp = CreateObject(“Outlook.Application”)

‘ Set the range of email data in Excel
Set MailRange = ThisWorkbook.Sheets(“Sheet1”).Range(“A2:C5”)

‘ Loop through each row and send an email
For Each cell In MailRange.Rows
Recipient = cell.Cells(1, 1).Value
Subject = cell.Cells(1, 2).Value
Body = cell.Cells(1, 3).Value

‘ Create a new email
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.Sender = “o@o.com”
.To = Recipient
.Subject = Subject
.Body = Body
.Send ‘ or use .Display to show the email before sending
End With
Set OutlookMail = Nothing
Next cell

‘ Clean up
Set OutlookApp = Nothing
End Sub

In the provided VBA code, we start by setting up the Outlook application using the CreateObject function. Then, we define the range of email data in Excel by specifying the worksheet and range.

The code loops through each row in the specified range and retrieves the recipient’s email address, subject, and body from the corresponding cells. It then creates a new email using the CreateItem method and populates the relevant fields. Finally, it sends the email using the .Send method.

Customize the code according to your specific email data range and desired email properties.

Conclusion): Using VBA in Excel, you can automate the process of sending emails to a list of people. By following the steps outlined in this article and using the provided VBA code example, you can streamline your email communication, saving time and ensuring accuracy in your email delivery.