Send the right attachment to the right recipient

Hi uipath community,

I have a folder with several excel files in it.
example: test1.xlsx test2.xlsx test3.xlsx

I would like to create a process that sends emails to the recipient test1@gmail.com test2@gmail.com test3@gmail.com

do someone have an idea how can i send the right attachment to the right sender using office 365 activities
like test1.xlsx = test1@gmail.com

thanks in advance

@tharuler
Please check below code

For each item in Directory.GetFiles(“C:\TestFolder”,"*.xlsx")

  • strRecipient = Path.GetFileNameWithoutExtension(item.ToString) +"@gmail.com"
  • //Do Something to send mail to strRecipient
1 Like

@Doanh can you explain what it does

It generates the email address base on the file name (without extension) + “@gmail.com” domain; the store it into strRecipient variable.
You can send email this variable

1 Like

the domain “@gmail” was just an example i can’t predict the domain of the email its changes everytime

what’s happening in my process :
I’m receiving an email
*I save the email address *
I create an excel file with some information in the body of the mail ( it a username name : first name )
*The excel file is saved in a folder *
At the end in the folder I have several excel files from previous mails

the more I think about it, the more I tell myself it’s impossible

@tharuler
It’s totally difference with your first post.
You should complete the Email Automation session of RPA Developer Foundation course in Academy, the you can do it well

i have done all the things i listed, i just write it to give you a better view

i have also completed RPA Developer Foundation, but i don’t have an idea how to link an already downloaded excel file to a specific user adress that i have saved from an incoming email

Are you using Outlook?

  1. Get the Mail Message
  2. Get From address from that Mail Message (e.g. strFrom)
  3. Get Attachments of that Mail Message and save to variable
  4. Loop all item in Attachments variable, save them to the folder corresponding with From address (e.g. “C:\Attachments” + strFrom folder)
    You also can write strFrom & name/path of saved attachments to excel file for manage

im using office 365