How to Automatically Email PDF Attachments Based on Excel File Names
Question details
The user wants to automate the process of sending customized PDF email attachments to recipients based on matching file names and email addresses stored in an Excel worksheet.

- Product
- Microsoft Excel, Microsoft Outlook
- Device & OS
- not provided
- Scenario
- A user needs to send recurring emails where each recipient receives a specific PDF attachment that matches their corresponding email address in an Excel list.
- Observed behavior
- Outlook and Excel lack a native, built-in feature to automatically match and attach local files based on spreadsheet data, requiring a custom automation solution.
Ensure your Excel worksheet is cleanly formatted with clear columns for recipient email addresses and the exact PDF file names, including the .pdf extension. Consolidate all corresponding PDF files into a single, easily accessible folder on your computer or cloud drive before configuring the automation.
Use Microsoft Power Automate for a No-Code Solution
Power Automate is a modern cloud-based tool that integrates Excel and Outlook to automate email attachments without writing complex scripts.
This method is ideal for users who store their files in the cloud. It connects your Excel data directly to Outlook via a visual flowchart interface.
Open your Excel workbook, select your data, and press Ctrl+T to format it as a Table. Save the workbook and upload all your PDF attachments to a OneDrive or SharePoint folder.
Log into Microsoft Power Automate online. Click 'Create' and choose either 'Scheduled cloud flow' for recurring emails or 'Instant cloud flow' to trigger it manually.
Add a new step and search for the 'Excel Online' connector. Select the 'List rows present in a table' action, then point it to your saved Excel file and Table name.
Add an 'Apply to each' control to loop through the rows. Inside the loop, add the 'Get file content' action for OneDrive/SharePoint, mapping the file name dynamically using the file name column from your Excel table.
Add the 'Send an email (V2)' action from the Outlook connector. Map the 'To' field to the email address column from Excel, write your subject and body, and attach the fetched PDF content in the advanced attachment fields.

Create a Custom VBA Macro in Excel
If your files are stored locally on your hard drive, you can write a VBA script in Excel to command Outlook to attach and send the customized PDFs.
Need a seamless alternative for your spreadsheet and automation tasks?
While highly specific Outlook automations rely on Microsoft's proprietary environment, WPS Office offers a lightweight, highly compatible alternative for managing all your daily spreadsheet tasks. With robust VBA support in its advanced versions and an intuitive interface, it's a powerful tool for productivity.
- 1. Download and Install: Visit the official WPS Office website to download and install the software for free.
- 2. Open Your Workbooks: Launch WPS Spreadsheets and directly open your existing .xlsx or .xlsm files containing your email data.
- 3. Manage Data and Scripts: Edit your mailing lists seamlessly or run compatible VBA macros in the WPS Advanced edition.

Frequently Asked Questions
Can I use Word Mail Merge to send different PDF attachments based on Excel data?
Standard Word Mail Merge does not support attaching unique, individual PDF files to emails. It can personalize the email body, but automatically attaching customized files requires either a third-party add-in or a VBA macro.
Why is my VBA macro failing to find the PDF files?
This typically happens if the file path defined in the VBA script is incorrect or if the file names in your Excel cells do not exactly match the actual PDF names on your hard drive. Ensure that the '.pdf' extension is included in the string and that there are no hidden trailing spaces in your Excel cells.
Is there a way to automate this process without knowing how to code?
Yes. Microsoft Power Automate provides a visual interface to build the automation. By connecting the Excel Online and Outlook connectors, you can map your columns to the email fields without writing any VBA code, provided your files are stored in a cloud environment like OneDrive.
Does WPS Spreadsheets support VBA macros for automation?
Yes, the advanced and professional versions of WPS Office fully support VBA. You can write, edit, and run many of the same automated scripts and macros that you would traditionally use in Microsoft Excel.




