How to save a new email containing specific attachment in local folder?

I’m working on Email Automation and I’m stuck in a scenario:
Example: Different emails are coming from hospital.But, I want to save the attachment from only those mails which are having subject as “Claim Clearance” and, also it contains attachment named Claim.pdf. This process should be continuous i.e as soon as the robot detect a new mail having subject “Claim Clearance” and “Claim.pdf” attachment, it will save that attachment in local folder.How can i achieve this functionality?

@Suyash0890 once you made connection with your mail or outlook you will get output as array of string.
-from there use for each and give input.
-inside the body use if condition like item.body.contains(“mention the specific content of body”) if it finds the mail with that body it goes to then section there you can use save attachments activity.

Thanks Venkat. But I’m bit confused how the robot will detect such kind of mails ?

Hi @Suyash0890,

Please refer attached workflow.

Shubham PratapMailFilter.xaml (7.3 KB)

Thanks Shubham :slightly_smiling_face:

1 Like

Hi Subh. Is is possible to make this process continuous i.e. if someone send the mail with subject “Claim clearance” and the name of attachment in the mail is “Claim.pdf” then the robot will automatically trigger and save the attachment in local folder?

Hi @Suyash0890,

Please find attached Workflow.

Shubham PratapFilterMail.xaml (10.6 KB)

Hi Shubh1801, I have a similar requirement and when i use the flow chart attached in your previous reply i keep getting validation error in the output with mailMgs even though same has been defined in variable.

Please help!!

Welcome to uipath community
May I know what was the. Alienation error you were getting

Cheers @HD001

I managed to pass through the validation error but now system throws back below error :frowning:

RemoteException wrapping System.InvalidCastException: Unable to cast object of type ‘System.Char’ to type ‘System.Net.Mail.Attachment’.
at UiPath.Core.Activities.ForEach1.InternalExecute(NativeActivityContext context, IEnumerator valueEnumerator) at UiPath.Core.Activities.ForEach1.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Hi @HD001,

Can you please send me your workflow.

Thank You,
Shubham Pratap