Get the Power Automate Starter Kit
A free 2-page guide with four flows to build next: save email attachments to OneDrive, send Forms answers to Excel, approve files and get a Monday list of overdue items. Plus a fix-it checklist and 4 expressions worth keeping.
Set Up the Excel Table and PDF Files
Located in our OneDrive is a folder called “Contracts” that holds a series of uniquely crafted PDF files along with an Excel file.

The Excel file has a table named “TableFiles” that holds information about the user’s name, email address, and name of the PDF file for that user.

The PDF files are contracts with information specific to each recipient’s negotiated details.

These files can be stored in OneDrive, SharePoint, or a different folder from the one holding the Excel file.
Prefer to skip Power Automate? You can also email Excel sheets as PDF with Office Scripts.
Our goal is to select the PDF files in the Excel document and then run a Power Automate Flow to perform all the merging and distribution of the data to the users.
Create an Instant Cloud Flow
Go to make.powerautomate.com and sign in with your work or school Microsoft 365 account.

Since we are creating a Flow from scratch, we select “Create” from the list of Power Automate categories on the left of the screen.

Flows start by defining the “trigger”; what is going to cause this Flow to execute its instructions.
Because our Flow is triggered based on cells selected in an Excel file, this falls under the purview of an Instant Cloud Flow.

Give the Flow a name, such as “Mail Merge with Attachment”.

Scroll down the list of triggers and select For a selected row (Excel Online (Business)).

Click “Create” to move to the next steps.
Connect the Flow to Your Excel Table
The next step is to tell the Flow where the Excel file is located and which table in the Excel file to consult when performing the email distribution.

Click New step to add the next action. In the new designer, click the + sign instead.
List the Files in the PDF Folder
We need our Flow to check the filename listed in the Excel table to see if there is a PDF in a folder that matches the filename. If so, we want to attach that folder’s file to the outgoing email message.

We want to loop through all files in a folder, checking for a matching name.
This is an action supported by OneDrive.
Search for OneDrive and select OneDrive for Business.

In the list of Actions, scroll down to locate “List Files in Folder”.

Click the Browse button to locate the folder holding the PDF files.

Click New step (or the + sign) to set up the loop.
Loop Through the Files and Match the Names
In the “Choose an Operation” panel, select “Control”.

Select the control labeled “Apply to Each”.

We need to use an output from the previous step. Scrolling down the list of Dynamic Content, we select “Value” from the list.

Next, click “Add an Action” to add another “Control”. This time we will use a “Condition”.

This allows checking to see if something occurs based on some form of logic and then act in one of two fashions. This is like writing an IF statement in Excel except it will be created using all point-and-click actions.
Our objective is to cross-check the name of the PDF file against the current row’s defined filename.
We need to point to the column in the Excel file labeled “File Name”.

Scrolling down the list of Dynamic Content, we come across an entry for the “File Name” field from the Excel file’s table.

Set the operator to is equal to and pick Display Name on the right. Display Name is the file name with its extension, so it matches how the names are written in the Excel table.

Get the Matching File’s Content
To define what happens if one of the PDF file’s display names matches the listed filename in the Excel cell, click the “Add an Action” located in the “If Yes” panel.

Like we did previously, in the “Choose an Operation” panel, search for “OneDrive” and select “OneDrive for Business”.

Scroll down the list of Actions to locate the “Get File Content” action.

In the “Get File Content” panel, scroll down the list of Dynamic Content and select “Id”.

Tip: if your file names always match exactly, you can skip the loop. Use the OneDrive action Get file content using path, with the folder path plus the File Name column from Excel.
Click “Add an Action” to begin setting up the email operation.
Build the Personalized Email
Search for “Outlook” to locate all Outlook-related operations.

Select the Action labeled “Send an Email (v2)”.

Set the To Field
We need the TO: field to be dynamic based on the “Email” column in the Excel table.

Click “Add Dynamic Content” and scroll down to select “Email” from the list.

Write the Subject
The subject can be a fixed statement for all email recipients, or it can be dynamically customized for each recipient. Making it dynamic would require an additional column in the table to hold all the unique subject lines.
For this example, we will go with the fixed statement “Your Contract”.
Write the Email Body
For the body, mix fixed text with dynamic content. For example: Hi [First Name], please find attached your file: [Name without extension]. Best regards. Each person sees their own name and file name.
The result of the To:, Subject:, and Body: elements appears as follows.

The only thing missing is the actual PDF attachment for each outgoing email message.
Attach the PDF
In the Send an email (V2) action, click Show advanced options. In the new designer, select Show all next to Advanced parameters.

The Advanced Options allows you to exercise several email-related actions, such as:
- Defining a sender’s email address
- Add CC or BCC email addresses
- Attach files
- Redirect replies to an alternate email address
- Set Importance levels
All of which can be defined dynamically.
To attach a PDF file:
- Set the “Attachment Name” option to the “Name” field in the Dynamic Content list
- Set the “Attachment Content” option to the “File Content” field in the Dynamic Content list

Click the Save button (upper-right) to save the Flow to our Power Automate library.

Run the Flow from Excel
Open the Excel file in Excel for the web. If it’s also open in the desktop app, close that copy first so two versions aren’t editing the same file.

To execute the Flow, select the Data tab and click Flow from the Automation group.

NOTE: If you don’t see the Flow button, go to Add-ins and install Microsoft Power Automate for Excel. In newer versions it appears as Automate Work on the Automate tab.
Want more ways to start flows from a workbook? Here’s how to use Power Automate in Excel.

Once you have activated Flow the following panel appears to the right of the Excel window listing all of the Power Automate Flows that are compatible with Excel.

If you select a single “File Name” cell in the table, the Flow will only process that single row’s PDF comparison and deliver a single email message.
If you select all the rows in the table (you can get away with only selecting the column of PDF filenames), the Flow will process all selected rows.
With the cell(s) selected, click the “Run” arrow.

If this is the first time you have used the Flow, you may need to sign in to your OneDrive account.

Click the “Run Flow” to execute the Flow process.

You can monitor the execution and completion status of the Flow by visiting the Flow Runs Page or click Done to exit the Flow panel.

Check the Results
The received email will appear as follows with the included attachment.

Opening the attached PDF, we see that it is the PDF file that was designated for the intended recipient.

Get the Power Automate Starter Kit
Download the Power Automate Starter Kit
One flow step by step, three more to try and a fix-it checklist.
Frequently Asked Questions
Can I send emails with different attachments from Excel without VBA?
Yes. Keep the names, email addresses and file names in an Excel table, and let a Power Automate flow match each row to its PDF and send it. You run the flow from Excel with no macros or paid add-ins.
Do I need a work or school account for this flow?
Yes. The For a selected row trigger belongs to the Excel Online (Business) connector, which works with files in OneDrive for Business and SharePoint. A personal Microsoft account will not connect.
Why does my flow not find the PDF file?
The file name in the Excel table must match the Display Name exactly, including the .pdf extension. Check spelling and extra spaces, and make sure List files in folder points to the right folder.
How do I send emails to several people at once?
Select several rows in the Excel table, or several cells in the File Name column, before you click Run flow. The flow runs once for each selected row.
Can I attach more than one file to each email?
Yes. In the Attachments section of Send an email (V2), add another item and set its name and content. You can also add CC addresses or change the Reply To address in the same section.
Do the PDF files have to be in the same folder as the Excel file?
No. They can sit in any OneDrive folder or in SharePoint. Point the List files in folder action at the folder that holds the PDFs.
Leila Gharani
Founder of XelPlus and ten-time Microsoft MVP. Leila helps over 500,000 professionals master Excel, Power BI, and data automation through practical, real-world training.








