November 29, 2024

Power Automate: 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.

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

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.

If you do this, then all files will be saved correctly.

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.

Have a suggestion of your own or disagree with something I said? Leave a comment or interact on Twitter and be sure to check out other Power Automate-related articles here.

Photo by Anne Nygård on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

9 thoughts on “Power Automate: Save all attachments when an email arrives

  1. Earlier it was not the issue but suddenly I also started facing same problem. It almost turned me mad from almost last 15 days!!!! Thanks god I found your article and it worked like a charm. It’s certainly a bug. The connector provided in templet flow for saving attachment, is different than the one we choose manually from list. Thank you Veryyyyyyyy Much!!!!

  2. Okay, I’m lost like a puppy in the woods.

    I’m trying to create my first flow. I want to open a .CSV file attached to an e-mail. I can’t even find the “When a new e-mail arrives” trigger. The new flow window opens with a list of actions but the search doesn’t find anything related to attachments.

    Maybe I’m not breaking my process down into small enough pieces? Maybe my project is too advanced for a beginner? I don’t think I’m looking for a specific answer from anyone here, as much as I’m looking for a more basic starting point.

    Thanks.

  3. And now it appears the app accessible directly from M365 is not the same as either the Teams or desktop versions?

  4. Hi. Thanks.
    I must be doing sometinhog wrong. It copies all the ttachements to a folder as it should. Unfortunatelly when the email has several attachements all attachements are saved with the same content. It saves with the correct name but always the same file. Any help?

  5. As Enterprise client Windows 10 User, I need help with automating via Cloud Flow to “Save email attachments to the File System” rather than OneDrive or SharePoint. As a novice, I am struggling with how to handle following:
    (1) DLP Policy as per Microsoft Community
    (2) Additional Install of on-premises data gateway to download which seems contradictory when my
    (A) Cloud Flow requires local resources?
    (B) Windows Client requires Windows Server 2012 R2?

Leave a Reply

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

Mastodon