All Content
Timespan
explore our new search
Processing .Zip Email Attachments Using Power Automate
Image Source: Shutterstock.com
Power Automate
Oct 19, 2022 9:03 PM

Processing .Zip Email Attachments Using Power Automate

by HubSite 365 about Tom Riha

Citizen DeveloperPower AutomateLearning Selection

Unlock the power of Microsofts Power Automate: Learn how to automate .zip email attachments for seamless processing and storage in SharePoint.

Automating Email Attachment Processing in Power Automate

In this blog post, Tom Riha guides us through the elaborate process of automatically handling .zip email attachments in Power Automate. The need for this arises from the question “I receive an email with a .zip file in the attachment, can I extract its contents before Power Automate saves it into SharePoint?”.

This intelligent platform plays a significant role in simplifying email attachments' management and ensures that they find their way to a predetermined location timeously. The tool, however, struggles when dealing with .zip files, given the need to unzip them before use - a task that requires manual intervention, which is not preferred.

The solution here is to let Power Automate take care of the unzipping procedure. Just like other attachments, a .zip file is first stored in services like SharePoint or OneDrive. The flow thereafter examines if the stored file is a .zip file and if so, extraction begins using the ‘Extract folder’ action.

The action prompts you to select the file's specific location (which you determined when saving it) and a folder for unzipping its contents. Note that the files can't be directly unzipped into a SharePoint library, as you always need to create another folder for them, preferably labelled with the date/time.

Once the files are extracted, they are initially in their separate folders which is not an ideal location unless you are good with a wild folder structure. However, since these files are stored in SharePoint, they can be moved anywhere you want.

The ‘Move file’ action is added here to shift the files using their Id to their final location; this could be a fixed site or a different location for each file. However, this creates a bit of confusion; we have the uncompressed files in the desired location (good) but then we still have the .zip file and the empty folder (bad). The following task is doing a cleanup.

Here is where the ‘Delete file’ action comes in handy, deleting the .zip file and the empty folder. The file deletion is the easy part, as you have its Id from when you created it. The challenge lies in deleting the folder because the tool does not have a designated action for that hence the need to improvise.

To summarise, when constructoring a flow with Power Automate keep in mind to consider how to automate the following steps. For example, once a .zip email attachment is stored, it has to be unzipped and cleaned up. Automating the whole series of steps is what leads to efficiency in handling email attachments. The more steps are automated, the less the need for manual interventions.

More info here

Automating tasks in Power Automate

Power Automate is exceptional at automating tasks and delivering desired outcomes. Manually supervising email attachments could prove quite time-consuming, especially for .zip files. However, thanks to Power Automate, email attachments can now be handled automatically, saving time for other important tasks.

Read the full article How to process .zip email attachment in Power Automate

Power Automate - Processing .Zip Email Attachments Using Power Automate

Learn about How to process .zip email attachment in Power Automate

In this blog, we're going to explain how you can handle .zip email attachments using a popular cloud-based tool, Power Automate. The main problem that we're addressing in this text is this - "I get an email with a .zip file in the attachment, can I extract its contents before this tool saves it to SharePoint?"

This robust utility can help you manage email attachments promptly. With each incoming email, it can identify if the email contains an attachment, and deposit it in a determined location. However, this process is not sufficient when dealing with .zip attachments. Simply saving the .zip file necessitates additional manual labor to extract it, and we're looking to avoid this. Therefore, the solution? Let your flow perform this task!

  • Unzip the .zip file

Initially, you must store the received file somewhere, like OneDrive or SharePoint, as you would save any other attachments. Due to the possibility of multiple attachments, ensure the attachment ends with .zip using a 'Condition'. If it checks all boxes, employ the ‘Extract folder’ action to unzip it.

Utilize the location of the file (which you have as it was just created by you) and a folder to extract the files for this action. Remember, you are not allowed to extract them directly into a SharePoint library, you must always allocate a new folder for the files. We recommend using the current date/time to avoid issues with character ':' in the time. This code might help: utcNow('yyyyMMdd-HHmmss').

  • Moving the extracted files

The files are unzipped now, but in their own folder. Generally, this is not prefered unless you're planning on a dynamic folder structure. However, the files are in SharePoint, meaning you can shift them elsewhere.

Utilize the ‘Move file’ action and transfer the files using their Id to the designated location. A consistent one, or a unique location suited to each document.

  • Deletion of the .zip and folder

By this point, the task has created a bit of a clutter. You've got the extracted files in the desired location (good!) but you've also got the .zip file and the empty folder (not so good). Therefore, it's time to do a cleanup.

Deleting the .zip is a straightforward task. Just incorporate the ‘Delete file’ action to erase it. You have the file Id since you created the file previously.

The deletion of the folder, on the other hand, is more complex. In absence of a dedicated action to remove folders, a "workaround" must be used. Implement an additional ‘Compose’ action to store the folder name before the files are extracted. This is due to the name of the folder being derived from the current date/time - meaning it would be altered post the ‘Extract folder’ process.

Once you're certain about the folder name utilized, apply the ‘Get files (properties only)’ with a Filter query on the folder path.

In conclusion, whenever you're constructing a flow, always consider the next step to make the system self-sufficient. If you just store the attachments, someone would have to manually unzip them. Why not also mechanize this “next step”? And after the files are extracted, someone still has to do the cleanup. Keep this cycle in mind and keep innovating!

More links on about How to process .zip email attachment in Power Automate

Solved: Microsoft Flow - Extract zipped email attachment o...
Mar 13, 2020 — My understanding is that 'On new email' task I have set it to take emails with the specified subject line, then pass that attachment to 'Extract ...
How to process .zip email attachment in Power Automate
Oct 9, 2022 — 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), ...

Keywords

Power Automate, .zip email attachment, process email attachment, automate .zip file, Power Automate tutorial, automate email tasks, handle .zip files, email automation, Power Automate .zip processing, understanding Power Automate