Download attachments from emails with a specific subject

Guys i am trying to download attachments from emails send to me with a specific subject .Help me as i see no options to dwnload attachments

1 Like

You can do like this way in screenshot. replace your subject text with “\number” part.



thank you @Phiggins and @aksh1yadav

Hi, can you please provide me the details of the variable ‘Mail’? I am not sure what this needs to contain? What should the default value be? Thanks!

I am able to download the attachment but when another application is trying to invoke excel file it is throwing error
“Excel application scope : Excel cannot access ‘Desktop’. The document may be read-only or encrypted.”

Please suggest how can we solve this issue?


Well check the path you are giving a file name along with desktop path? or just Desktop and other possibility is check that excel file is password protected or not. if so then pass the password also in Excel application scope properties.


I have provided correct path to download the excel file, the issue is with OPENING that excel file, and also the file is not password protected.


Then please cross check the path you are passing in Excel application scope. try to write line it and observe the path.

I don’t want to hardcode the path.

is it not possible to have the path which I am giving (C:\Users\anjmishra\Desktop) plus the excel file name (Details.xlsx)

Hi @anjalimishra,
To determine the path of the desktop where the robot is running you can use:

Actually I assigned this to a string variable called folderPath and inserted the following command in Excel application scope.
folderPath + “Details.xlsx”

I hope that helps!


I try to do like this but I get always an error and I don’t know what im doing wrong.

Image bellow

Can anyone help please. Thanks


Well I find a solution to my problem, the filter must be done like the example on this page

“@SQL=”“urn:schemas:httpmail:subject”" like ‘Subject That you like to search’"

I hope that helps someone.


Well the problem is because you are not getting result count to process so.



The solution is simple actually. You have to:

 Select the For each activity > Go to TypeArgument attribute on the menu > Choose  System.Net.Mail.MailMessage from the list 

That should solve the problem.


Hey I am also looking for the same. Any idea regarding the mail variable?

hey, I am also looking for the same. I have to download the attachment inside a mail with a particular subject. I tried giving “/number” but no luck. Can you please help me out? attaching the (5.3 KB)

@amithvs i Changed ur xaml file. check it once Mail_Trigger_Sample (1).xaml (22.4 KB)

but body of the mail is showing like this.

@amithvs,Use Regex
Regex.Replace(item.Body, "<[^>]+>| ", string.Empty)

1 Like