I am building an automation in which i am extracting a file from outlook.
I have scenario where i have to extract a zip file which is in the mail as an attachment. I am using unzip activity. The way i a using is extract any file attachment in the mail. save in a temp folder, then i have to move the actual Shared Folder.
The code is working fine till now until i encountered a new scenario.
Let me explain my code.
For each mail message with attachment save attachment a Temp folder. before saving it will clear the folder.
Then read file format, if the file is anything apart from zip .. then move to share folder
If it is a zip file it will unzip into the same folder then
I use a for each file in the folder move to Shared folder
the issue is some are straight zip .. where the files are zipped into a .zip.
I have a new scenario where the .zip has a folder and then files are in the folder.
My current code extracting folder and then saving the zip as well.
It is moving .zip to shared folder and not getting with the folder.
How can i handle this?
Can you please help my with this.
supplementary request: The current code is a bit slow..not sure how to optimize the code.
In your scenario, the issue occurs when the ZIP file contains a folder structure instead of files directly at the root level. When the ZIP is extracted, the files end up inside a subfolder, but the automation only processes files from the main temp directory.
A simple way to handle this in UiPath is to use the “Include subfolders” option available in the For Each File in Folder activity.
When this option is enabled, the activity will iterate through all files inside the folder and any nested folders, ensuring that files extracted from ZIP archives (even if they are inside folders) are processed correctly.
Steps to fix the issue:
Extract the ZIP file into the temporary folder as you are currently doing.
Use For Each File in Folder to iterate through the extracted files.
Enable the Include subfolders option.
Move the files to the shared folder.
Example flow:
Clear Temp Folder
Save Attachment to Temp Folder
If file type = .zip → Extract to Temp Folder
Use For Each File in Folder (Include subfolders = True)