Open attachment in Outlook, read excel file without saving first

Hello,

Is there any way i could open attachment from email, read the file and store variables from it without saving first? I will only save it if certain criteria is met, and then create my own filename based on information in the attached file.

The Outlook.Attachment object does not actually contain the attached file, It contains a link to the attached file, with some associated metadata.

The attachment is a file. if you want to interact with it, you have to treat it like a file, and that means saving it out to the local disk or should be on Exchange server.

It is not able to do via the Outlook Object Model, but MAPI i.e Microsoft Messaging Api surely allows you that.

Tip - Redemption Also might help with Existing Outlook Object model.

Regards…!!
Aksh

2 Likes

Thanks!

Is it then possible to use If and check if there is a attachment? and If the email contain attachement, how do I define custom name to it?

yes check this thread

at the time of writing attachment as per above Thread example just path your dynamic name from variable.

Regards…!!
Aksh

This thread is also very good, it shows you how you can use ‘filter’ in the ‘save attachments’ activity to only save attachments which meet certain criteria. How to save only a specific file type using Save Attachment activity?

My attachments are all .xlsx files, and i want to store the file name in a variable so i could use move file to rename it. How could I store the name in a variable when saving attachment?

Why you will use move activity to just rename your attachment.
Instead you can directly pass the path where you want to save your attachment with your given name.

in That example screenshot below their is one variable like below in that it is using default attachment which is in the mail.
image

if you want to give it your name then just assign that name or a variable containing your custom name and replace with attachment.Name.

Regards…!!
Aksh

1 Like

I did not work, i guess i’m doing something wrong or makes it all to difficult.

Now i have stored the file name in a variable called: fileName . This is define by Directory.GetFiles and then i find the number in the Array.

I then create a new variable called varExcel that define the new name. This is made up by intCounter and the name from fileName.

Could i have change the name while saving the attachement instead of doing all this? Just store the name of the attachement and just add the number from the intCounter into a new variable that i could call up later?

Hi Akash
Thanks for your inputs on this issue.
It would be really helpful of you can let us know how to invoke Microsoft Messaging API in Uipath or if you can share any such object.