How to insert attachment in UI path SMTP activity

Just Don’t use the for -each loop and make only use of the content inside for each-

and change the item value with your single file path in assign statement.


I’ve tried SMTP for sending attachment. It throws error has “The process cannot access the file because it is being used by another process.”


What if you close the files that you are trying to send as attachment? (ex. if you have an excel file, close it first and check if you still get the error)

Hi @ovi ,

It is already in closed state only. But still I’m getting this error. Error will not appears when commenting the Move activity.

Process: Send mail with attachment and move the file to seperate folder.

Actually the above process is working fine for sending mail through Outlook and then moving the file to Processed folder. But the same proces will not work for SMTP.

I’m iterating the file through items.


I think you have to dispose the attachments after sending the email:

Hi, I’m using SMTP. Is this same for that too?


Great, after using the Invoke method, It’s worked fine.


Got Folder not found exception executing above code,Can you help me to Add multiple files as attachments

Hello Aksh - I am faving difficulty in adding the To Address in the SMTP mail message the way you have shown it in your sample. I try something like - Assign mail.To = new MailAddress(""). Please help in this regard. Also, is there a way to send multiple attachments using outlook?


I tried this step, however I am getting error as “The given path’s format is not supported.”
Kindly help me out.

Thank you,

Hi All

I want to pick a single file checking file name contains certain string and sent it uisng outlook , not in for each, please help with some sample


Hi aksh1yadav,
I try attachment that you are provided it send mail but unable to attach the files.

Hi @aksh1yadav,

I am facing an issue while sending SMTP Mail message, the error is week authentication as shown below,

Mahesh Gundekar

Hey @mahesh.gundekar

The Problem might be with your given path. Check sample for more assistance.

It is due to Security Feature by Gmail for their accounts safety.If an app or device doesn’t meet our security standards, Google will block anyone who tries to sign in from that app or device. Because these apps and devices are easier to break into, blocking them helps keep your account safe.

So if you will access your account from the devices or methods which does not support latest security compliance which has been identified with google then you will get such error to secure your account.

so, you have two options:

  1. Option 1: Install a more secure app that uses stronger security measures. All Google products, like Gmail, use the latest security measures.

  2. Option 2: Change your settings to allow less secure apps into your account. We don’t recommend this option because it can make it easier for someone to break into your account. If you want to allow access anyway, follow these steps:



Hi @aksh1yadav,

Thanks a lot for your valuable suggestion.

Thanks & regards,
Mahesh Gundekar

Is it possible in another methd

my scenario is : i have some files in one folder. i want attach that files . How ?

Hello @spatlolla001,

I would create a list of all files in the directory you’re looking in, you can do this with an assign activity and use Directory.GetFiles(“put the path to the directory here”). If you’re only looking for .pdf files you should do C:\SomeDirectory*.pdf in the path.

Then you can use the invoke as before on all the files in your new list.

I hope this helps.

Hey Aksh

I have an excel spreadsheet with Name, E-mail and Transaction ID.

I also have folders within a specific path that have Transaction ID as their name.

For each row in the excel spreadsheet.

I want the bot to go into each row, pull out E-mail address, go to the relevant folder and retrieve all pdf files within that folder. and send the e-mail.

Can I do that with your xaml example?

hi @aksh1yadav,

I tried your solution for sending an attachments in email.I got the below error message.

Can you please help me here.