Hi
I need to filter email’s and save the attachments in a seperate folder.
I have an excel which has ‘Country Name’.I am reading the excel, creating folder in country name and filtering the eamil subject with country name. However attachments are being saved in a single folder.
EX: Argentina has 2 mails which has 2 attachments each.
Colombia has 2 emails which has 3 attachments each.
Countries with attachments…
I need to save the Argentina attachments in Argentina folder. Chile attachments in Chile folder…
Is that possible. Please help me with this
Thanks.
we’re filtering the subject by an excel file. Let me attach the excel and .xaml for your reference Counrty list 3.xlsx (9.3 KB) Dispatcher-2.xaml (13.6 KB)
This document outlines a professional UiPath workflow designed to automate the process of fetching emails with attachments from Outlook, creating separate folders for each email based on its subject, and saving the attachments within those folders. The approach utilizes built-in UiPath activities, adhering to their guidelines against custom activities.
Workflow Structure:
Retrieve Emails:
Employ the Get Outlook Mail activity to retrieve emails from a specified Outlook folder or based on defined criteria (e.g., unread emails, emails with specific keywords).
Iterate Through Emails:
Implement a For Each activity to iterate through each email retrieved in step 1.
Check for Attachments:
Inside the For Each loop, utilize an If activity to check if the current email has attachments. This can be achieved by evaluating the MailMessage.Attachments.Count property. Only emails with attachments proceed further.
Dynamic Folder Creation:
Within the If activity (true branch), construct a dynamic folder path for the current email’s attachments. Here’s how to achieve this professionally:
Define a base folder path variable (e.g., baseFolderPath = @"C:\Attachments\") to store the root location for saving attachments.
Extract the subject of the current email using MailMessage.Subject.
Employ System.IO.Path.Combine to seamlessly create the full folder path by concatenating the base folder path with the email subject. This ensures proper handling of directory separators across different operating systems.
Enclose the folder creation in a Try Catch block to gracefully handle potential exceptions during directory creation (e.g., insufficient permissions, existing folder with the same name).
Save Email Attachments:
Within the If activity’s true branch, leverage the Save Mail Attachments activity. Configure the activity’s properties as follows:
Set the FolderPath property to the dynamically created folder path. This ensures attachments are saved in the designated folder for that particular email.
Bind the MailMessage property to the current email object being processed in the For Each loop.
Execute the Save Mail Attachments activity to initiate downloading and saving all attachments from the current email into the corresponding folder.
Error Handling:
Implement appropriate error handling mechanisms throughout the workflow. Utilize Try Catch blocks to capture exceptions that might arise during folder creation, file operations, or interaction with Outlook. Log or display meaningful error messages for better troubleshooting.
I completed the workflow.
result is getting correctly.
but if i use filter in ‘get outlook mail activity’ it is not reading any mails?
how can i fix it
attaching my .Xaml for reference Dispatcher-2.xaml (20.7 KB)