Method 1 – 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.
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.
View the Result
- An Outlook window will appear, and you’ll see the desired file attachment.
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 – 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.
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.
View the Result
- An Outlook window will appear, and you’ll see the desired file 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
- How to Format Address Labels in Excel
- How to Copy and Paste Excel Table into Outlook Email
- Creating a Mailing List in Excel
- How to Change Date Format in Excel Mail Merge
- How to Mail Merge from Excel to Powerpoint
- How to Send Email from Excel List
<< Go Back To Mail Merge Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!