Currently I am downloading attachments from my outlook using = for each loop + If Statement to equal to email Subject + save attachment activity.
Is it possible to Download attachment directly from get outlook activity using subject line and save it in local folder without any looping ?
Anyone has any idea ,Please share with me .
We don’t have any option in get outlook mail messages activity to save attachments.I think ,we need to write logic as you mentioned above.
We do not have option to save attachment without lookif you want to save from multiple emails…but we can avoid the if condition by adding filters in outlook get mail messages activity.This will get only the emails with required subject
Yes, it is possible to download an attachment from the
Get Outlook Mail Messages activity and save it to a local folder in UiPath. To do this, you can use the following steps:
- Use the
Get Outlook Mail Messages activity to retrieve the email message containing the attachment you want to download.
- Iterate through the retrieved email messages using a
For Each loop.
- For each email message, use the
Get Attachments activity to retrieve the attachments.
- Iterate through the attachments using another
For Each loop.
- For each attachment, use the
Save Attachment activity to save the attachment to a local folder.
Here is an example of how this could be implemented in UiPath:
// Set the email account, folder, and local folder where the attachment will be saved.
string emailAccount = "email@example.com";
string folder = "Inbox";
string localFolder = "C:\\Attachments";
// Use the Get Outlook Mail Messages activity to retrieve the email messages.
IEnumerable<MailMessage> messages = GetOutlookMailMessages.GetMessages(emailAccount, folder);
// Iterate through the email messages.
foreach (MailMessage message in messages)
// Get the attachments for the current email message.
IEnumerable<Attachment> attachments = GetAttachments.Get(message);
// Iterate through the attachments.
foreach (Attachment attachment in attachments)
// Save the attachment to the local folder.
SaveAttachment.Save(attachment, localFolder, attachment.Name);