How to save specific attachments from mail UiPath
While automating the business process the often used application is outlook.
These are used to receive inputs or to notify users of the bot’s progress or any error reports.
Sometimes we also receive mails that consist of attachments that need to be processed by the bot.
Let’s say we have a mail which consists of excel and pdf attachments but we need to process only excel attachment.
To successfully achieve this task we need to save only excel attachments.
Now, we will see the practical implementation of this task:
Step1: Drag and Drop a Get Outlook Mail Message Activity and set the properties as shown below:
- mailMessages: The list of mail messages which are read from outlook.
- Top: It will read the top 10 mails in the outlook.
- MarkAsRead: It will make the mail as Read after reading it.
- OnlyUnreadMessages: It will read only unread mails from outlook.
Step2: Drag and Drop a For each activity and provide the Get Outlook Mail Message Activity output as input as shown below:
Also change the Type Argument to System.Net.Mail.MailMessage.
Step3: Drag and Drop a Save Attachment Activity and provide the properties as shown below:
Here the Filter play’s a major role in selecting the specific files from attachments.
In this filter we are saving only excel attachments from mail.
If you want to save different attachments, you can use the below syntax:
- FolderPath: Provide the file path where you need to store the attachments.
- Message: Provide the mail message item here.
- Filter: For saving the attachments from the mail.
This is how we can save a specific attachment from mail or the different specific attachments from a mail.