Is it possible to Download attachment from get outlook activity and save it in local folder

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 .

Hi @Krishnakumar_Vasudevan

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.

@Krishnakumar_Vasudevan

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

“[subject]=‘Required subject’”

Cheers

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:

  1. Use the Get Outlook Mail Messages activity to retrieve the email message containing the attachment you want to download.
  2. Iterate through the retrieved email messages using a For Each loop.
  3. For each email message, use the Get Attachments activity to retrieve the attachments.
  4. Iterate through the attachments using another For Each loop.
  5. 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:

Copy code

// Set the email account, folder, and local folder where the attachment will be saved.
string emailAccount = "user@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);