How to Convert CSV Email Attachments to Excel Format in Power Automate

Cloudmersive
4 min read1 day ago

--

We can never have too many solutions for automating CSV to Excel conversions (and vice versa). If we’re making that conversion consistently, we want it done before we have to think about it.

Automating CSV to Excel conversion workflows directly from incoming email attachments is one quick way to make our life easier.

Power Automate makes it incredibly simple to automate file content retrieval workflows with built-in Outlook and SharePoint connectors, and Cloudmersive connectors offer dozens of file format conversion options — including numerous CSV- and Excel-focused APIs.

Walkthrough: Convert CSV to Excel directly from email attachment

In this article, we’ll walk through a quick Automated cloud flow that converts CSV email attachments from a specific sender to Excel and saves the resulting Excel file(s) in our system. We’ll get the whole workflow done in just a couple of steps.

First things first, we’ll select the option to create an Automated cloud flow that uses the When a new email arrives (V3) trigger action from the Office 365 Outlook connector.

For testing purposes, we’ll configure our trigger action to look for emails from our own email address (we’ll send ourselves an email with an attachment when we run our test later on).

We’ll also ask our trigger action to Include Attachments and look for emails Only with Attachments.

Next, we’ll place a Condition in our flow.

In our Condition, we’ll check if Attachments Name values from our trigger action contain the “.csv” extension. This filters out non-CSV files for the next step in our flow, and it also engages a For each control to ensure our flow cycles through each attachment present in the triggering email.

In the True branch of our condition, we’ll now implement our CSV to Excel conversion action.

We’ll find this action on the Cloudmersive Document Conversion connector actions list. The full name is Convert CSV to Excel XLSX Spreadsheet.

Upon selecting this action, we’ll need to create our connection, which requires a free Cloudmersive API key. We can get one of those by registering a free account on the Cloudmersive website. With a free API key, we’ll be able to make up to 800 API calls each month with zero commitments (our total will reset at the beginning of each month).

Once our connection is saved, we’ll configure our CSV to Excel conversion request by passing the Attachments Content and Attachments Name values from our trigger action as arguments into our two request parameters.

We’ll now use a Create file action to save our Excel content on a SharePoint team site.

We can reuse the name of our original CSV file by using the slice() function to remove the “.csv” extension (this requires us to use the negative string index 0, -4 on the Attachments Name value).

We’ll then place OutputContent from our CSV to Excel conversion action in the File Content field.

At this point, we’ll save our flow and run a test.

Since we’re testing an Automated cloud flow, we’ll need to perform the trigger action ourselves (i.e., email ourselves a .csv file) and then check if the conversion worked correctly.

When our flow finishes running, we should find the Excel version of our CSV file on our SharePoint team site.

And we’re all done! We can now test this with multiple attachments including both CSV and non-CSV files to make sure we’re filtering out the wrong content types effectively.

Conclusion

In this article, we learned how to set up a simple automated flow in Power Automate that converts CSV files to Excel directly from inbound emails and stores them in SharePoint. We can now employ this flow for email correspondences with folks who regularly share data in CSV format.

If you found this walkthrough helpful, remember to follow our blog!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet