Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Solution
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

How to process .zip email attachment in Power Automate

Posted on October 9, 2022October 9, 2022 by Tom

“I receive an email with a .zip file in the attachment, can I extract its contents before Power Automate saves it into SharePoint?”


Power Automate is a great tool to help you organise email attachments. Every time you receive an email, it can check if it contains an attachment, and store it in a specific location. But for attached .zip files it’s not enough. You don’t want to just save the .zip file as you can hardly use it before you extract it. Just saving it will need a manual work to extract it – not the ideal situation. Why not let the flow do this work?

Extract the .zip file

Before you can extract the file, you must store it somewhere, e.g. in OneDrive or SharePoint. Just save it as you’d save any other attachment.

As there can be more than one attachments, check if the attachment ends with .zip in a ‘Condition’. If it does, extract it with the ‘Extract folder’ action.

It’ll ask you for the location of the file (which you know since you just created it), and a folder where it should extract the files. You can’t extract them directly into a SharePoint library, you must always create a new folder for the files, e.g. using the current date/time.

Important note: the action seems to have problem with : character in the time! I recommend using a custom format without the colon:

utcNow('yyyyMMdd-HHmmss')
Power Automate zip email attachment

Move the files into a common folder

The files are now extracted, but in their own folder. That’s not a good place unless you plan using a wild folder structure. But since they’re now stored in SharePoint, you can move them anywhere you want.

Add the ‘Move file’ action and move the files using their Id in the final location. A fixed one, or a different location for each file.

Cleanup the .zip file and the folder

At this moment the flow created a lot of mess. You have the extracted files in the desired location (good!) but you’ve got also the .zip file and the empty folder (bad). Since you probably don’t want to keep all of it, you should do a cleanup.

Deleting the .zip file is the easier task – add the ‘Delete file’ action and delete it. You already have the file Id as you created the file a few steps before.

The much more complicated task is deletion of the folder. Since Power Automate doesn’t have a dedicated action to delete folders, you must use a “workaround”.

Firstly, you must get the Id of the folder as it’s not among the outputs of ‘Extract folder’.

Add an extra ‘Compose’ action to store the folder name before you extract the files. The reason is that the folder name is using the current date/time – it’d be different after the ‘Extract folder’ action.

Power Automate zip email attachment

Once you know what folder name was used, add ‘Get files (properties only)’ with a Filter query on the folder path. You already moved all the files from the folder so it’ll return just 1 item – the folder itself.

substringof('@{outputs('Compose')}', FileRef)
Power Automate zip email attachment

The folder itself can then be deleted using the ‘Delete item’ action. Enter the site URL, type in the library name (it won’t be in the dropdown), and use the returned Id to delete the folder.

The whole flow

Power Automate zip email attachment

Summary

When you build a Power Automate flow, you should always think about the next step to automate – you just saved the email attachment, but what about the .zip files? If you just save them then somebody will have to extract them. Why don’t you automate also this “next step”? And when the flow extracts them, somebody has to do the cleanup – what about this step? And the next one, and the next one…?


🚀 Master Power Automate

Join 2,100+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

10 thoughts on “How to process .zip email attachment in Power Automate”

  1. Pingback: Low code/no code:如何用Power App建立PDF/原生不用瀏覽器/Power Automate自動解壓縮附件 - 口吃、閱讀筆記、雲端運算、資料分析:中途筆記
  2. Noah Davis says:
    December 8, 2022 at 7:51 pm

    The .zip file I receive is password protected, requiring a password before the file will expand the contents. Any tips on how to solve for that?

    Any guidance would be great. Thank you.

    Reply
    1. Tom says:
      December 15, 2022 at 1:43 pm

      Hello Noah,
      not really, I never did this for password protected files.

      Reply
  3. Karen Knapp says:
    April 12, 2023 at 9:47 pm

    I am struggling to get this to work for me. I seem to have the same scenario described here and I have been relatively successful except for the last step which is the workaround to delete the folder created in the Compose step. I have been successful in the Compose step, the Extract Folder, Apply to Each and Delete File. But when I do the Get files(properties only) with the Substringof on the Filter Query the output value is always null. I cannot seem to get the output I need for the final Delete Item step.

    Reply
    1. Tom says:
      May 1, 2023 at 3:34 pm

      Hello Karen,
      I’d check the filter in the flow run history, it’ll show you what folder path it tried to use. That way you can see if it’s the same as the actual folder path in the document library or if it differs (and you can adjust it accordingly).

      Reply
    2. Andres Monroy says:
      June 16, 2023 at 9:36 pm

      Hi Karen,

      I was having a similar issue with the last step, but I think I found a solution. After testing your flow, go to the raw inputs of the “Get file (properties only)” action and copy the table value. Then go to your “Delete item” action and paste the table value in the List Name. This seem to have fixed the issue for me.

      Hope this helps!

      Reply
  4. Siddhartha says:
    June 1, 2023 at 2:59 pm

    Hi Tom, Can you please suggest what is the limitation of the file size for this action? Extract Folder.
    I have some GB’s of data to extract, will that work?

    Many Thanks

    Reply
    1. Tom says:
      August 12, 2023 at 10:34 pm

      Hello Siddhartha,
      I have no idea, you’ll have to try it on some of your big files and you’ll see.

      Reply
  5. Chelsea says:
    October 18, 2023 at 10:18 pm

    Are you able to change the file name to something specific? For example “Finance Report 10.18.23”?

    This was very helpful!

    Reply
    1. Tom says:
      November 19, 2023 at 1:45 pm

      Hello Chelsea,
      no, you can just extract the files. But you could extend the flow to search for the specific file, let it be by file name or the date when it was created (it’ll be right after the extraction) and you can rename it.

      Reply

Leave a Reply Cancel reply

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

🚀 Master Power Automate

Join 2,100+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Still exchanging emails to get things approved?

Get the Approval Process solution to skip the hard part and deploy an automated, fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Are your approvals stuck due to unavailable approvers?

Keep your approvals running with the Approval task delegation app! Reassign any existing approval task to another user with a single click - no more waiting for absent approvers!

Power Automate approval task delegation ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundle—everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes