How to save perticular file from outlook, when the attachments contains multiple files


how can I save the single attachment out off multiple attachments from a single mail through “outlook save Attachments activity”.

Thanks & Regards



That activity only saves all attachments unfortunately.

But, you could iterate the attachments, check f.e. their name or MIME type, get the ContentStream and save it to a file.
Just remember to Close/Dispose of the streams to not leave stray handles.

Can’t provide an example right now - maybe a little later or someone else will be able to help.



hi @punee

Thanks to @andrzej.kniola to guide me on a little doubt.

here i am attaching the attached solution for your above problem.

OutLookAttachement.xaml (16.1 KB)

Let me know feedback of this solution.



Hi @andrzej.kniola and @aksh1yadav,

Thanks for the solution, Its working fine for me.

Thanks & Regards

Hi All,

We will appreciate you if you give us exact solution file(.xaml)


It is already there. you can download it

Or you are asking for other thing?


Hi @aksh1yadav,

I tried using your xaml. It’s unable to find the attachment.
Also, when I save the mail messages, every field of the mail (including attachments) is empty, except the subject.
Any idea on this?

Hi @aksh1yadav,

I also tried your xaml but I am also facing same issue as like @Sriv is facing.

Please find below screen shot of email

except the subject all things are blank.

Is there any dependency of UiPath version currently I am working on latest UiPath version(Version 2016.2.6274)


This Still works with my enterprise account email. Do not know but may be enterprise security issues. many others also faced this and they were saying the same.

Will you give it a try on your personal laptop or system with outlook and let us know the outcome of it. Will be helpful to identify problem in your case.



Use Filter Property of the “Save Attachment” activity.

How to use filter?

Hi @sanjay.erram,

Hi, this filter will also download files that include “xls” in the filename, so for instance “xls-test.exe” will be downloaded where as “legit-file.xLs” will not.
To make the filter case-insensitive, apply this filter: “.*(?i)(.xlsx|.xls)”

I do not know how to specifically and only filter xls/xlsx files, that only examines the file extension. :frowning:

Hi, I have implemented your code in a loop of emails, each email will save the attachments and doing so, I have encountered this.

Filter Emails: Process Email: Invoke workflow file: Invoke method Stream : Cannot access a closed Stream.

I have remove the line of code where in you dispose the stream and filestream, question, In uipath, what will be the implication doing so?

Hey @marcus

If a class implements IDisposable, then you should dispose it so any resources gets closed/cleaned up asap instead of relying on the garbage collector.Classes such as Stream, StreamReader, StreamWriter etc implements IDisposable interface h that means, we can call Dispose() method on objects of these classes.


Because you were disposing that stream object inside a loop so when your loop was processing second time the stream object you already have been disposed. so make that part outside of your loop. :slight_smile:

The contract for IDisposable.Dispose explicitly requires that calling it on an object which will never be used again will be at worst harmless.
I would recommend(Personal point of view) calling either IDisposable.Dispose or a method called Dispose on every IDisposable object if you don’t wanna use that object again :slight_smile:



I tried using ur attached workflow and its working fine. I just wanted to know tht why are we using the invoke function in this? What is the use of them?

Thanks in advance.


Is it possible to check if the attachement name contains a certain fileformat (example: .xlsx), if not return the email with the attachement?

I then need to get the senders email as well

Attached workflow was executing fine for one email with specified extension,if multiple mails are present with same extension of attachments then attachments are not getting saved.OutLookAttachement.xaml (16.1 KB)

1 Like