How to do a Mail Merge from Excel to Outlook with Attachments (2 Methods)

Method 1 – Mail Merge from Excel to Outlook with Single Attachment

In this method, we’ll demonstrate how to perform a mail merge from Excel to Outlook with a single attachment. Let’s start by introducing our Excel dataset so you can understand what we’re aiming to accomplish in this article. The dataset includes a person’s name, email ID, and the file they require.

Embedding VBA to Mail Merge with Single Attachment

To achieve this, we’ll use Visual Basic for Applications (VBA). Follow these steps:

Enable the Developer Tab

  • Open Excel.
  • Go to the ribbon and select the Developer tab.
  • If you don’t see the Developer tab, enable it by going to Excel Options > Customize Ribbon > Developer (check the box).

Access the VBA Editor

  • Click on the Visual Basic button in the Code group on the Developer tab.

Alternatively, press Alt+F11 to open the VBA editor.

Insert a Module

  • In the VBA window, go to Insert and select Module.

 

Add the VBA Code

  • Enter the following code into the module:
Sub Single_attachment()
Dim appOutlook As Object
Dim Email As Object
Dim source, mailto As String
Set appOutlook = CreateObject("Outlook.Application")
Set Email = appOutlook.CreateItem(olMailItem)
mailto = mailto & Cells(2, 2) & ";"
source = "F:\SOFTEKO\61-0055\New folder\" & Cells(2, 3)
Email.attachments.Add source
ThisWorkbook.Save
source = ThisWorkbook.FullName
Email.attachments.Add source
Email.To = mailto
Email.Subject = "Important Sheets"
Email.Body = "Greetings Everyone," & vbNewLine & "Please go through the Sheets." & vbNewLine & "Regards."
Email.Display
End Sub

Run the Macro

  • Close the Visual Basic window.
  • Press Alt+F8 to open the Macro dialog box.
  • Select Single_attachment from the list of macros and click Run.

How to Mail Merge from Excel to Outlook with Attachments

View the Result

  • An Outlook window will appear, and you’ll see the desired file attachment.

How to Mail Merge from Excel to Outlook with Attachments

VBA Code Explanation

  • The Single_attachment subroutine creates an Outlook email with an attachment.
  • It retrieves email addresses and file paths from the Excel sheet.
  • The email subject is set to Important Sheets, and the body contains a greeting and instructions.
 

Note: Make sure to save the Excel file and the required document in the same folder for this method to work effectively.

Read More: How to Mail Merge from Excel to Outlook


Method 2 – Mail Merge from Excel to Outlook with Multiple Attachments

In this method, we’ll demonstrate how to mail merge from Excel to Outlook with multiple attachments. Let’s start by introducing our Excel dataset so you can understand our goal. The dataset includes names, email IDs, and the required files for specific individuals.

Implementing VBA to Mail Merge with Multiple Attachments

To achieve this, follow these steps:

Enable the Developer Tab

  • Open Excel.
  • Go to the ribbon and select the “Developer” tab.
  • If you don’t see the Developer tab, enable it by going to Excel Options > Customize Ribbon > Developer (check the box).

Access the VBA Editor

  • Click on the Visual Basic button in the Code group on the Developer tab.

Alternatively, press Alt+F11 to open the VBA editor.

Insert a Module

  • In the VBA window, go to Insert and select Module.

 

Add the VBA Code

  • Enter the following code into the module:
Sub attachments()
Dim appOutlook As Object
Dim Email As Object
Dim source, mailto As String
Dim i, j As Integer
Set appOutlook = CreateObject("Outlook.Application")
Set Email = appOutlook.CreateItem(olMailItem)
For i = 2 To 5
    mailto = mailto & Cells(i, 2) & ";"
Next i
For j = 2 To 5
    source = "F:\SOFTEKO\61-0055\New folder\" & Cells(j, 3)
    Email.attachments.Add source
Next
ThisWorkbook.Save
source = ThisWorkbook.FullName
Email.attachments.Add source
Email.To = mailto
Email.Subject = "Important Sheets"
Email.Body = "Greetings Everyone," & vbNewLine & "Please go through the Sheets." & vbNewLine & "Regards."
Email.Display
End Sub

Run the Macro

  • Close the Visual Basic window.
  • Press Alt+F8 to open the Macro dialog box.
  • Select attachments from the list of macros and click Run.

How to Mail Merge from Excel to Outlook with Attachments

View the Result

  • An Outlook window will appear, and you’ll see the desired file attachments.

How to Mail Merge from Excel to Outlook with Attachments

VBA Code Explanation

  • The attachments subroutine creates an Outlook email with multiple attachments.
  • It retrieves email addresses and file paths from the Excel sheet.
  • The email subject is set to Important Sheets, and the body contains a greeting and instructions.

Note:

Ensure that you save the Excel file and the required documents in the same folder for this method to work effectively.

Read More: Mail Merge from Excel to Excel


Download Practice Workbook

You can download the practice workbook from here:


Related Articles

<< Go Back To Mail Merge Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Saquib Ahmad Shuvo
Saquib Ahmad Shuvo

Saquib Ahmad Bhuiyan, holding a BSc degree in Naval Architecture & Marine Engineering from Bangladesh University of Engineering and Technology, skillfully integrates engineering expertise with a passion for Excel. He provides solutions to complex issues as an Excel & VBA Content Developer for ExcelDemy Forum. He demonstrates an enthusiastic mindset and adeptness in managing critical situations with finesse, showcasing his commitment to excellence. Apart from creating Excel tutorials, he is interested in Data Analysis with MS Excel, Rhinoceros,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo