Power Automate Tutorial Part 2: Filter and Extract CSV Email Attachments to Excel

Continuing Our Journey
If you're reading this blog, I would like to thank you first for taking your time!
Let's continue from where we left off in the previous article. If you haven't seen the previous article, please take your time and read it, as this blog is a continuation of that. Here's the link: Power Automate Tutorial - Part 1
Important clarification: In this tutorial, we're not simply saving email attachments to OneDrive. Instead, we're reading the data inside CSV email attachments and writing that data into an Excel file stored in OneDrive. This is much more powerful than just file storage!
Let's get started...
Step 7: Add a Condition to Filter CSV Files
Why are we adding this condition?
Emails can have multiple types of attachments (PDFs, images, Word documents, etc.). We only want to process CSV files, so this condition acts as a filter to ensure we're only working with the correct file type. This prevents errors and unnecessary processing.
Click the "+" icon inside the "Apply to each 2" action
The "Add an action" panel will open on the left side
In the search field, type "condition"
Select "Condition" under the Control section (see screenshot below)

The "Condition" action will be added to your flow with a parameters panel on the left side
(Optional) Rename the action to "Condition - Check if CSV" for better clarity but I have used “Condition 1“
In the first field (with placeholder "Choose a value"), type '/' to access dynamic content
Select "name" from the "When a new email arrives (V3)" section (this represents the attachment filename)

In the middle dropdown, select "ends with"
In the third field, type
.csv(this ensures we only process CSV files)
See the screenshot below

Close the side panel. Your flow should look like the screenshot below:

Step 8: Get the Attachment Name Using Compose
Why are we adding this action?
The Compose action stores the attachment's filename for later use. This is helpful for logging, debugging, or referencing which file we're processing. It's like creating a variable that holds the CSV filename.
Click the "+" icon inside the "If yes" (True) branch of the condition
Search for "compose" in the search field
Select "Compose" under Data Operation (see screenshot below)

The Compose panel will open on the left side
(Optional) Rename it to "Get Attachment Name". I have used “Compose 1“

In the Inputs field, you have two options:
Option A - Using Dynamic Content:
Click the Inputs field
Select "Name" dynamically from "When a new email arrives (V3)"
Option B - Using Expression (Recommended):
Click the Inputs field
Click the fx icon to open the expression editor
Type the expression:
item()?['Name']Click "Add"

What does item()?['Name'] mean?
This expression retrieves the current attachment's name in the loop. item() refers to the current item being processed in the "Apply to each" loop, and ['Name'] gets its filename property.
Your Compose action should now look like the screenshot below:

Step 9: Get the Attachment Content
Why are we adding this action?
Now that we've confirmed the attachment is a CSV file, we need to actually retrieve the file's content (the data inside it). The "Get Attachment" action downloads the attachment from the email so we can read and process its data.
Click the "+" icon below the "Get Attachment Name" (Compose) action
Search for "get attachment"
Select "Get Attachment (V2)" from the Office 365 Outlook section (see screenshot below)

The action panel will open with two required fields:
Message Id:
Click the field
Select Dynamic content (⚡ icon)
Choose "Message Id" from "When a new email arrives (V3)" section
This tells Power Automate which email to get the attachment fromAttachment Id:
Click the field
Click the fx (Expression) icon
Type the expression:
items('Apply_for_each_2')?['id']Click "Add"
This identifies the specific attachment within that email
Important: Replace 'Apply_for_each_2' with your actual "Apply to each" action name if you renamed it differently. The name should match exactly, with underscores replacing spaces.
Your "Get Attachment (V2)" action should now look like the screenshot below:
You can rename anything I have used “Get Attachment (V2) 1“

Coming up next: We'll parse the CSV data and write it to our Excel file in OneDrive!
Quick Recap
So far, we've:
✅ Set up an email trigger to monitor incoming emails
✅ Looped through all attachments in the email
✅ Filtered to process only CSV files
✅ Retrieved the CSV filename and content
A Quick Note Before Part 3
I need to say thank you for your patience and support.😍
I realise this tutorial is now extending into a third part, and that might feel like a lot. I genuinely appreciate you taking the time to follow along, and I hope it's not too frustrating that we're not done yet!
Here's why I'm doing it this way: Power Automate itself is remarkably simple—once you're clicking through the interface, it's intuitive and straightforward. But I'm being thorough in these articles because I want to explain the reasoning behind each step, not just the mechanics. I want you to finish this series feeling confident to build your own automations, not just copy mine. 😎
I'm also being honest here—I've been away from blogging for a while, and I'm carving out special time from my schedule to write this series properly. That means taking it slow, explaining things clearly, and making sure even absolute beginners can follow along.
The love and support you showed on my previous blog means the world to me. It's what motivates me to keep going and finish this series the right way.
See you in Part 3, where we'll tie everything together by parsing the CSV and writing the data to Excel.
Click Here for Part 3 We're in the home stretch!
Thanks again for being here. 🙌



