Send different attachment in multiple emails using Outlook

Hi, could you please advise how to send emails to a different recipients with different attachment and each folder with attachment has a different recipient. I have created excel file with name, email and company names, CC and attachments. The body of the emails will be the same. The way to get to the folder needs to be dynamic as it contains year and Quarter which will change. My intension is to use each for row but not sure how to add a different attachment to a different recipients. For example the folder where the file will be saved is as follow: “\nlamspntap103.upcit.ds.upc.biz\HQHome$\Jarous\Desktop\Testing RPA\DMR_CHAR"+YearDMR+”"+Datetime.ParseExact(Month,“MMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)+“-”+Month+“\DMR\Templates\Arr\LLG - Arr Template - FY”+YearDMR+" “+Quarter+”.xlsx"
Thank you for your help and advice.

Hey,
If I understand you correctly you have excel file and on every row and you have information about recipients, file path to attachment etc.
So you can use ‘for each row in data table’ extracted from excel and you can send email to every recipient from every row. You have also file path. So you can do something like that:
sendEmailCommunity.zip (9.3 KB)

Hi, I do not have attachment there as it needs to by dynamic as there is Year and Quarter which will change. So I think I can not add the link to xls file just like that.

So how do you know what the file will be named ? Where do you get the path to the attachment ?

I pick the file from one folder, run the xls and make some changes then the file is saved in below folder with current Quarter and year under current year and Month with dynamic variables.
“\nlamspntap103.upcit.ds.upc.biz\HQHome$\Jarous\Desktop\Testing RPA\DMR_CHAR”+YearDMR+“”+Datetime.ParseExact(Month,“MMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)+“-”+Month+“\DMR\Templates\Arr\LLG - Arr Template - FY”+YearDMR+" “+Quarter+”.xlsx"
in excel where I have names and emails I am not able to copy the link as is above as it has dynamic variables, so not sure how to do it and attach the file to correct email.
Thank you for your help and advice.

I added to my excel file path which I created as formula as year and Q needs to be dynamic,
and in the attachment I added the way to the folder + row(“FilePath”).ToString. However I am getting error: Send Outlook Mail Message: Cannot find this file. Verify the path and file name are correct.



could you please advise what I am doing wrong.
thank you.

Hey,
before you add this string concatenation (with file path) please try use ‘write line’ activity or assign path to the variable and verify if the path is correct and exists.
On the other hand you can check the folder with files and take only one which match the condition with name pattern.
Use Directory.Getfiles(“folder path”) to get list of files
In for each loop you add ‘if’ activity and get file which will match to your pattern.

If you need example like workflow file please let me know :slight_smile:

1 Like

hi it would be really helpful if you could share workflow example. Thank you

Hi, in my workflow I have Path check for folder so shall I do the same for File?
image

Hey @jarous,
maybe on the evening I will find some time to give you an example :slight_smile:

At the end I put all the attachments to one folder and it works

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.