Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

Save email attachment to a specific SharePoint folder (Power Automate)

Posted on July 10, 2022July 10, 2022 by Tom

“I’ve got a dedicated mailbox collecting emails with various attachments. Can I use Power Automate to save them from the email to a specific SharePoint folder based on the attachment type?”


One of the basic use cases for Power Automate is to save attachments from incoming emails. You receive an email in your mailbox and it’ll automatically store it to OneDrive or a SharePoint site. But with the basic solution it’ll save all the attachments to one place. That’s still a lot of work for you to organise them later.

Wouldn’t it be nice if you could automate also this step? To save the attachment in a specific folder based on its type?

Create a configuration list

As explained in a previous article, you don’t want to put the folder configuration directly into a flow. You want to keep the attachment-folder configuration outside of it, in a configuration list. And that’s the first step – create a configuration list in SharePoint. The list needs just 2 columns, the file type (or some other part of the file name) and the folder.

Use it to get the file location

Now, with the configuration list in place you can start with the flow. Start with the trigger ‘When a new email arrives’, potentially with a trigger condition on attachments or email subject(s). Among the trigger outputs will be also the email attachments and their properties, including the attachment name.

The attachment name is important because that’s what the processing is based on. Extract the part that’s used in the configuration list, in this case the file extension…

last(split(items('Apply_to_each')?['name'],'.'))

… and use it in a lookup to the configuration list.

Save the file

The ‘Get items’ action will return one item from the configuration list, the one with the destination folder. Use it in the folder path in the ‘Create file’ action.

Power Automate save email attachment folder

Don’t worry about the automatically added ‘Apply to each 2’. Since there’s only 1 entry in the configuration list for the file type it’ll always return only 1 item = it’ll run only once.

Summary

You can use Power Automate not only to save email attachments, but also to save each attachment in a specific folder. Firstly, create a configuration list based on a part of the file name. Secondly, parse the file name and use it to lookup the config list. Finally, once you have the folder from the config list, use it to store the file in the right folder.

The benefit of using a configuration list is that you can easily add another type/folder configuration. Just add them to the configuration list and flow will take care of the rest, including creation of the folder(s).


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Check if email already exists in Outlook contacts (Power Automate)August 7, 2022
  • Set permissions for a SharePoint list or library with Power AutomateAugust 3, 2022
  • Handle deleted files in synchronised SP library in Power AutomateJuly 31, 2022
  • Create item with lookup column in a dynamic list (Power Automate)July 27, 2022
  • How to move list between SharePoint tenants with Power AutomateJuly 24, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme