cancel
Showing results for 
Search instead for 
Did you mean: 
manuelstgomes

Save All Attachments When an Email Arrives

One of the best ways to deal with email is not to deal with it at all. With Power Automate, you can check each email that arrives, and it fits a certain condition and automatically performs a specific action. Today I’ll explain how to save all attachments automatically when an email arrives.

Note: This post was inspired in finding a solution for the Power Automate Community because the obvious way of doing this will result in an error

The obvious way and why it won’t work

If you’re building this Flow, you would think you would only need 3 steps:

  1. When a new email arrives
  2. Apply to Each Attachment
  3. Save file.
  4. (Optional) move or archive the email

Since the trigger contains the attachments, you would build something like this.

small-Screenshot_2020-12-28_at_18_42_20.jpg

 

But this will save invalid files of 4bytes each. The attachment object only returns the ID of the attachment, not the attachment itself.

 

small-Screenshot_2020-12-28_at_18_44_43.jpg

 

I don’t know if this is intended, but it made me spend some time figuring out why the Flow was not working when the logic is 100% correct.

The solution

The solution is simple. You need to fetch the email by the ID you receive in the trigger, and then you’ll have the attachment object that you would expect.

small-Screenshot_2021-02-01_at_17_01_50.jpg

 

Final thoughts

The issue is quite a head-scratcher, but fortunately, it has a simple solution.

In the end, you can move the email using the “Move Email” action. With this, you will have one less email to process and avoid the tedious work to save all attachments from an email and archiving them.

This is the kind of automation we like. The one that does 100% of the work for us.

Comments

Hi @manuelstgomes ,

Good one!

This is a common scenario in many business. It might be storing attachments in SharePoint. Let's say email sent thru the website "contact us" would be sent to a common email account and if it is stored in SharePoint document library that has access to a team. Then anyone from the team can work on the request.

HI @ArchitectMadhan 

That's awesome. I love the idea.

I used OneDrive, but the process to store in SharePoint should be similar.

Thanks a lot

Manuel

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/