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

email
outlook
activities
attachment

#1

Hi,

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

Thanks & Regards
Puneeth


How to save only a specific file type using Save Attachment activity?
How can I find a specific attachment in emails?
Save Attached files from my outlook in local folder
How to find out if Mail has attachments or if it has no attachments?
Saving Outlook attachment
#2

Hi,

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.

Regards,
Andrzej


How to rename the attachment file after downloading from outlook.?
#3

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.

Regards…!!


Outlook attachment download
How to save only a specific file type using Save Attachment activity?
How to rename the attachment file after downloading from outlook.?
Condition to check if item is nothing
Open attachment in Outlook, read excel file without saving first
#4

Hi @andrzej.kniola and @aksh1yadav,

Thanks for the solution, Its working fine for me.

Thanks & Regards
Punee


#5

Hi All,

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

Thanks,
Sandy


#6

It is already there. you can download it

Or you are asking for other thing?

Regards…!!
Aksh


#7

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?


#8

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)

Thanks,
Sandy


#9

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.

Regards…!!
Aksh


#10

Hi,

Use Filter Property of the “Save Attachment” activity.


#11

How to use filter?


#12

Hi @sanjay.erram,


#13

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:


#14

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.


#15

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?


#16

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.

Regards…!!
Aksh


#17

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:

Regards…!!
Aksh


#19

Hi,

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.


#20

Hello,

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


#21

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)