Download Attachments from Outlook

Hi Guys,

I have couple of emails in my outlook which contains an attachment in every email.
Based on subject " XXXXXYYYYY",i want to read all the emails and i want to download all the attachments from the emails and want to store in a folder, where i want to create a folder dynamically.

Please help on this. If any sample code is available please attach.

Thanks

Hi @avinash14

Uipath have the activity called Save Attachments to save all the attachment in a particular mail, for creating folder dynamically we have the activity called Create Folder before you create you have to check the condition called Folder Exists or not.

Hope this will helpful.

Regards
JothyPrasanth M

Hi Jothy,

Thanks for the response. I couldnt find any activity called Create Folder, is this the correct name of the activity ? I can see Create File & Create Directory.

And one more thing suggest how to check the Folder Exists Condition.

Thanks

1.Get outlook mail messages.
2.Use save attachment activity to save your attachments .
3.File separation…

For your easy understanding



6 Likes

Hi @avinash14

U can use to check the folder already exists or not using the Activity called Path Exists
image

For creating folder u can use Create Directory.

Note: The Same kind of scenario is available in Email Automation Tutorials you can just go through it.

Regards
JothyPrasanth M

1 Like

Thanks Sob … Got Cleared.

Thanks Jothy…!

You can check similar example in Level 1 training in email automation and add code for saving attachments to folder…

We can read email from outlook and Save into a folder.

  1. Use Get outlook mail message activity
    image
  2. Input the required value in the properties window (User Name,Mail Folder name)
    image
  3. Create an variable of type Email messages.
    image
  4. Use a for each look to extract each email messages
    image
  5. Make sure you have changed the object type of For each loop as Email Messages
    image

By following above steps you will able to download all the attachment to a folder, you can further customize this Ex. different file type will store in different folder.

Thanks.
Asish

6 Likes

Hi!
I hope you find yourself very well.

I have a problem with download attachments, my sequence is fine but I do not download the attachments.

Help me, please.

Can any one send me (.xaml) please to download the attachment from email and save that

Can i get the variables used in your flow?

Hi @Sob

As i’m new to RPA can u guide me how to perform this task
i performed till image 2
i missed something in that im still getting an error
thanks in advance

Regards,
myshudhage(myshudhage@gmail.com)

cheers @Sob :smiley:

Robot:

Variables:

rply @Myshudhage

@Myshudhage
-use get outlook mail messages activity and give the details,this will give you output as list of mail messages.
-use for each and change the out argument into net.mail.messages
-inside the bod use if condition as item.subject.contains(“value in subject which you are looking for”)
it goes to then section if it finds there use path exists change it into folder and give the folder path which you want to create and the output of path exists give you output as boolean under it use if condition there give the path exists output variable.
-if the path exists it goes then section there use save attachments and if there is no path exists it goes to else section there use create directory and pass the path you want to create and below it use save attachments.that’s it

1 Like

thanks @venkatmalla6 for the reply i have shared few SS and let me know where i went wrong

even i tried with this solution as well but there was no output i just opened and closed nothing happened

cheers :smiley:

@Myshudhage seems like you haven’t store the getoutlook mail messages output just have a look in first screenshot there in properties panel you didn’t store the output.

@venkatmalla6 i have just shared the procedure i have given the output variable but still its the same

@venkatmalla6 variable for outlook

@Myshudhage then the output which you stored as mailid but in for each the input you given is email change the input to mailid

@Myshudhage and also in for each activity in properties panel change the argument from object type to net.mail.messages