Send Personalized Emails from Excel with Outlook VBA

A short mail merge macro that sends one personalised Outlook email per row, with an optional attachment and a status column so nobody gets the same email twice.

Cover for the guide: Send personalised emails from Excel with Outlook and VBA

Sending the same email to a list of clients, each with their own name and attachment, is one of the most common requests I get. Word mail merge can do part of it, but attachments and tracking who has already been emailed get messy fast. A few lines of VBA in Excel handle the whole job.

How the sheet is laid out

Create a sheet called Mailing with these headers in row 1:

  • A Name
  • B Email
  • C Subject
  • D Message (write {Name} where the name should go)
  • E Attachment path, optional
  • F Status, filled in by the macro

The macro

Option Explicit

' Outlook mail merge from Excel
' Free module from sourabsaha.com
'
' Sheet "Mailing", headers in row 1:
'   A Name | B Email | C Subject | D Message | E Attachment path (optional) | F Status
' Write {Name} anywhere in the message to insert the person's name.
' Keep SendNow = False to review drafts first, then set it to True.

Private Const SendNow As Boolean = False

Public Sub SendMailMerge()
    Dim ws As Worksheet
    Dim olApp As Object, olMail As Object
    Dim lastRow As Long, r As Long, done As Long
    Dim attachPath As String

    Set ws = ThisWorkbook.Worksheets("Mailing")
    lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
    If lastRow < 2 Then
        MsgBox "Add at least one email address in column B.", vbExclamation
        Exit Sub
    End If

    Set olApp = CreateObject("Outlook.Application")

    For r = 2 To lastRow
        If Len(ws.Cells(r, "B").Value) > 0 And ws.Cells(r, "F").Value <> "Sent" Then
            Set olMail = olApp.CreateItem(0)
            With olMail
                .To = ws.Cells(r, "B").Value
                .Subject = ws.Cells(r, "C").Value
                .Body = Replace(ws.Cells(r, "D").Value, "{Name}", ws.Cells(r, "A").Value)
                attachPath = Trim$(ws.Cells(r, "E").Value)
                If Len(attachPath) > 0 Then
                    If Len(Dir(attachPath)) > 0 Then .Attachments.Add attachPath
                End If
                If SendNow Then .Send Else .Display
            End With
            ws.Cells(r, "F").Value = IIf(SendNow, "Sent", "Draft opened")
            done = done + 1
            Set olMail = Nothing
        End If
    Next r

    Set olApp = Nothing
    MsgBox done & " email(s) processed.", vbInformation
End Sub

How it works

  • Rows already marked Sent are skipped, so you can run it again safely after adding new rows.
  • With SendNow = False each email opens as a draft for you to check. Switch it to True once you are happy.
  • It uses late binding (CreateObject), so you do not need to add the Outlook reference library.

Free download

Download the module and import it into your own workbook:

Download Outlook-Mail-Merge.bas

  1. Open your workbook and press Alt + F11 to open the VBA editor.
  2. Choose File, Import File and pick the downloaded .bas file.
  3. Save the workbook as Excel Macro-Enabled Workbook (.xlsm).
  4. Run the macro from Developer, Macros, or assign it to a button.

Need HTML emails, a different sender account or a schedule? Send me a message and I can extend it for you.

Common problems and quick fixes

  • Outlook asks for permission for every mail. Your antivirus is out of date or turned off. Outlook only shows that warning when it cannot confirm the computer is protected.
  • Mails stay in the Outbox. Outlook must be open and online. Use .Display instead of .Send for a test run, and check one message by hand before you send the batch.
  • The attachment path is wrong. Use the full path, for example C:\Reports\March.pdf, and check it with Dir before attaching so the macro skips missing files.
  • Gmail marks the mails as spam. Send from your work address, keep the message personal, and send in small batches of fifty or fewer.

Frequently asked questions

Does it work with the new Outlook?

No. The new Outlook for Windows does not support VBA. Keep classic Outlook installed, or use Power Automate for the new version.

Can I send from a shared mailbox?

Yes. Set the SentOnBehalfOfName property on each mail to the shared address, as long as you have Send As rights for it.

Can I add a different attachment for each person?

Yes. Put the file path in a column and attach it inside the loop. Leave the cell empty and the macro sends that person no attachment.

Related guides

Need this built for your own workbook? I write Outlook, PDF and reporting macros for US businesses every week, tested on a copy of your file and delivered with a short how-to video. See my Excel VBA automation service or get a free quote in under a minute.

12 Excel VBA macros that save hours every week

The small macros I use on almost every client file. One .bas file you import once, with clear comments and step by step instructions.

  • Unhide, protect and unprotect all sheets
  • Delete blank rows and clean messy text
  • Highlight duplicates in any range
  • Split one sheet into many by a column
  • Combine every sheet into one
  • Export each sheet to its own PDF
  • Clickable sheet index, dated backups and a formula audit list

No spam. Your email is never shared. Privacy Policy

Sourab Saha, Data Analyst

About the author

Sourab Saha · Data Analyst · Kolkata, India

I’m Sourab Saha, a data analyst and automation developer from Kolkata, India, with more than ten years of experience turning manual data work into clean, automated systems. On Fiverr and Upwork I have delivered over 500 data and automation projects for clients in the US, UK, Europe, Australia and the Middle East, with a 5.0 rating on both platforms. My toolkit is Excel VBA, SQL, Power BI and DAX, Python with Selenium, and Google Apps Script. I collect data from files, databases and websites, clean it, model it and present it so decisions take minutes instead of days. I build and test every tool on your real data, deliver it with a short walkthrough, and keep revising until it works exactly the way you need. Alongside my freelance work, since 2024 I have also worked as a Data Analyst for AH Group of Industries, a US healthcare group, building automated reports and Power BI dashboards from billing, payroll, audit and attendance data.

Rated 5.0 on Fiverr and Upwork, with more than 500 automation projects delivered and over ten years of Excel VBA. You get a fixed price before any work starts, your files stay private on your order page, and every order comes with a proper invoice.

WhatsApp