How to Send Mail Merge Emails Through Outlook With Attachments per Recipient
🔍 WiseChecker

How to Send Mail Merge Emails Through Outlook With Attachments per Recipient

You need to send personalized emails with attachments that differ for each recipient. The standard Word mail merge feature sends the same document to everyone. It does not natively attach separate files per recipient. This article explains how to use a Directory merge combined with a VBA macro to attach unique files from a folder to individual Outlook emails.

Key Takeaways: Sending Personalized Emails With Individual Attachments

  • Word Directory merge + Outlook VBA macro: Combines a directory-style merge that lists all recipient data with a macro that creates individual emails and attaches files based on a field value.
  • Data source with a “AttachmentPath” column: Each recipient row must include the full file path to the unique attachment so the macro knows which file to attach.
  • Macro runs from the merged Word document: After the directory merge populates a Word table, one macro execution sends all emails and attaches the correct file for each row.

ADVERTISEMENT

Why Word Mail Merge Cannot Attach Files Per Recipient by Default

Word mail merge has two main output types: Letters and E-mail Messages. The E-mail Messages option sends the merged document as the email body or an attachment. But it attaches the same document to every email. There is no built-in field or rule to attach a file that changes per recipient.

The solution uses a Directory merge type. A Directory merge does not create separate pages or emails. It fills a single Word table with one row per recipient. That table is then processed by a VBA macro that reads each row, creates an Outlook email, and attaches the file specified in the row.

What You Need Before Starting

  • Microsoft Outlook configured with a working email account
  • Word 2019, Word 2021, or Word for Microsoft 365
  • A data source such as an Excel worksheet or Access table with columns for Name, Email, Subject, and AttachmentPath
  • A folder on your computer or network containing the attachment files named exactly as they appear in the AttachmentPath column
  • Macros enabled in Word: File > Options > Trust Center > Trust Center Settings > Macro Settings > Enable all macros

Steps to Set Up the Data Source and Directory Merge

  1. Prepare your data source
    In Excel, create columns: FirstName, LastName, EmailAddress, SubjectLine, AttachmentPath. Fill AttachmentPath with full file paths such as C:\Attachments\Invoice_123.pdf. Save and close the workbook.
  2. Open a new blank Word document
    Go to Mailings > Start Mail Merge > Directory. This tells Word to build a single table of all records.
  3. Select recipients
    Click Select Recipients > Use an Existing List. Browse to your Excel file. In the Select Table dialog, choose the sheet that contains your data. Make sure the first row of your sheet contains column headers.
  4. Insert merge fields into the document
    Insert a Word table with one row and as many columns as you need. In each cell, click Mailings > Insert Merge Field and choose the matching column name. Include a cell for AttachmentPath even though it will not appear in the final email. This field tells the macro which file to attach.
  5. Complete the merge
    Click Mailings > Finish & Merge > Edit Individual Documents. In the Merge to New Document dialog, choose All. Word generates a new document with one table row per recipient. Save this merged document as MergedOutput.docx.

ADVERTISEMENT

Steps to Create and Run the VBA Macro

  1. Open the Visual Basic Editor
    Press Alt+F11 in Word. In the Project pane, double-click Normal or the current document project to open a code module.
  2. Insert a new module
    Click Insert > Module. Paste the following macro code into the module:
    Sub SendMailWithAttachments()
        Dim objOutlook As Object
        Dim objMail As Object
        Dim objDoc As Document
        Dim objTable As Table
        Dim iRow As Integer
        Dim strTo As String
        Dim strSubject As String
        Dim strAttachment As String
        
        Set objDoc = ActiveDocument
        Set objTable = objDoc.Tables(1)
        Set objOutlook = CreateObject("Outlook.Application")
        
        For iRow = 2 To objTable.Rows.Count
            strTo = objTable.Cell(iRow, 2).Range.Text
            strTo = Left(strTo, Len(strTo) - 2) ' Remove end-of-cell markers
            strSubject = objTable.Cell(iRow, 4).Range.Text
            strSubject = Left(strSubject, Len(strSubject) - 2)
            strAttachment = objTable.Cell(iRow, 5).Range.Text
            strAttachment = Left(strAttachment, Len(strAttachment) - 2)
            
            Set objMail = objOutlook.CreateItem(0) ' olMailItem
            With objMail
                .To = strTo
                .Subject = strSubject
                .Body = "Dear " & objTable.Cell(iRow, 1).Range.Text & vbCrLf & vbCrLf & "Please find your document attached."
                If Dir(strAttachment) <> "" Then
                    .Attachments.Add strAttachment
                End If
                .Send
            End With
            Set objMail = Nothing
        Next iRow
        
        Set objOutlook = Nothing
        Set objDoc = Nothing
        MsgBox "Emails sent successfully."
    End Sub
    

    Note: Adjust cell column numbers to match your table layout. Column 1 is the first column in your table.

  3. Run the macro
    Close the VBA editor. In the merged document (MergedOutput.docx), press Alt+F8, select SendMailWithAttachments, and click Run. Outlook sends each email with the correct attachment.

Common Issues When Sending Mail Merge Emails With Attachments

The macro says “Email sent successfully” but no email arrives

Outlook may move the message to the Outbox and not send it automatically. Open Outlook, go to File > Options > Mail, and under Send messages, make sure the check box for “Send immediately when connected” is checked. Alternatively, change the macro line .Send to .Display to review each email before sending manually.

Attachment file not found error

The AttachmentPath column must contain the exact full path. A missing drive letter, wrong folder name, or extra space causes the macro to skip the attachment. Verify the path by pasting it into Windows File Explorer. If your file paths contain spaces, the macro still works because it uses the full string.

Email addresses are not recognized by Outlook

The macro reads the cell text including paragraph markers. The Left(strTo, Len(strTo) - 2) function removes the two end-of-cell characters. If your table has extra spaces or line breaks inside the cell, use the Trim function: strTo = Trim(Left(strTo, Len(strTo) - 2)).

Directory Merge vs Standard Mail Merge for Attachments

Item Standard Mail Merge (E-mail Messages) Directory Merge + VBA Macro
Attachment per recipient Not supported Supported via AttachmentPath field
Email body content Merged document or text Custom body defined in macro
Setup complexity Low Moderate
Requires macro permissions No Yes
Supports different subject lines Yes Yes
Works with Outlook on the web No No

You can now send personalized emails with unique attachments using Word and Outlook. Test the macro with a small set of recipients first. For advanced customization, modify the macro to include an HTML email body by setting the .HTMLBody property instead of .Body. This method works with Word for Microsoft 365, Word 2021, and Word 2019 on Windows.

ADVERTISEMENT