Save Outlook Attachment

Hi, I’m currently trying to save all attachment from an email, but when i went to check the folder that the attachment is supposed to save at…not all the attachments have been downloaded. So i manually used Outlook’s Save All Attachments function, and some file(s) made Outlook to give me this error message “The operation failed. An object cannot be found”

Are there any ways to get the File Names of all the attachment and trace which ones have been successfully Downloaded? As of now It stops saving attachments right before the one with the error


We can get all the attachments collection from a mail item using “mail.Attachments” property of the mail. This will return a AttachmentCollection type output, then we can compare the name of each item from this collection with the files saved in the directory from the mails.

Apologies for the poor explanation,
What i was meaning is … lets say there are 20 attachments but UiPath only managed to save 18 since the 19th attachment have the aforementioned error which caused it to stop saving at the 18th, i was asking if theres any way to also trace the file Names of the 19th and 20th attachment even with the outlook error message


Check the attached workflow for the shown activities, you can get the list of file name which are not saved from your mails.

GetOutlookMails.xaml (9.2 KB)

Hi, just wondering what does the last assign do?

Were we able to download those missing files manually
Kindly try that once and let’s check whether we are getting the same error or not
—and then to check with whether all the attachments are download are not, hope these steps would help you resolve this
—once after getting the mail list variable from get outlook mail activity with a variable named list_mails
—now use a FOR EACH loop and pass the above variable as input list_mails and change the type argument as System.Net.Mail.MailMessage
—inside the loop use a IF condition like this
If true it will get into THEN part of if condition where
—use a assign activity with a variable named
counter = counter + 1
Where counter is a variable of type int32 with default value as 0 defined in the variable panel
—followed by that we need to use another FOR EACH activity to get the attachment name and save them To a variable
—and in that for each activity pass the input variable as item.Attachments and change the type argument as System.Net.Mails.Attachments
And change the variable name from item to attachments
—now in this inner for each loop use a add to collections activity where in the property panel mention as list_attachments in collections property where list_attachments is a variable of type System.Collections.Generic.List(of String) with default value as New List(of string) defined in the variable panel and in the item property of add to collections activity mention as attachments.Name
So that the attachment name will saved to the list variable
—next to this add to collection in the inner for each loop use SAVE ATTACHMENT activity where mention the mail as item and folder path where we want to save it
—now next to this inner for each loop within the then part use a assign activity to increment the counter value
counter = counter +1

—Now to simply check with the file count that got saved and compare them with actual count of attachments, next to the outer for each loop use a IF condition like this
If true then goes to THEN part and we are good else will go to ELSE part

Kindly try this and let know for any queries or clarification
Cheers @Dave88