Dynamic Email Content from Excel

I am using the outlook send mail activity to send confirmation emails to potential job candidates. I have created an email template using notepad (and have checked the isHTML option in UI Path). I have an excel file that I want it to read from and include certain details in the body of the email such as date and time. I am looking for suggestions of the best way incorporate these variables into my HTML text file and the workflow.

See attached excel file example.
List of Emails to Send.xlsx (8.7 KB)

Hi @jklein

In body section of send outlook mail message you can give

“hi”+environment.newline+row(“Date”). ToString+row(“Time”).ToString

Thanks
Ashwin.S

1 Like

Hi @AshwinS2 thanks for your reply. How would I incorporate that into a Text file which I am using as the body of the email? Sorry if this is a simple question, I am a bit new to this.

Hi @jklein

Want to know based on the email template you want to send a mail message based on date and time am I right or you want to spend it in a text file

Thanks
Ashwin.S

@AshwinS2 I have attached the extract from the text file which represents the template for the body

Kindly email me back to confirm that the below date and time works for you for an in-person interview. Below you will find the details of your interview with our company:

  When:
  Time:
  Where:
  Interviewers:

We look forward to meeting with you!

in your html text file template where ever you want to add dynamic data place this expression {0}, {1} llike that
and then before sending the smtp mail read your html template and then use this syntax
String.Format(html_template_varibler,DateTime.Now.ToString,dtSystemExceptions.Rows.Count.ToString,… based on how many are added in the template same data you need to pass here) and give this into smtp email subject

@kalyanDev thank you very much. So if I am understanding correctly I can insert the expression into my text file, for example - We are looking forward to meeting you on {Date}.

I do not completely understand the next step after that. Where should the syntax you mentioned go and what activity do I need to include in the workflow for it to work?

Okay… Tomorrow I’ll share some sample file and xaml so that you will get easily

You need to mention the syntax like this we are looking for forward to meeting you on {0} and save it this past up-to preparing the html document (if you want to add more dynamic values use {1} ,{2} and so on
Next in code read this document and save it in one variable next take one string variable then assign the syntax as mentioned above and pass this string variable in smtp mail activity subject session
This will give you bit confusion any how I’ll try to send tomorrow some sample xaml

<body>

	<p>Hi Team,<br><br>
	BOT <b>"Bill As_Is"</b> System Exceptions summary report on <b>{0}</b><br><br></p>

	<p>Total number of system exceptions: <b>{1}</b></p>
	<p>Thanks,</p>

	<p>Bill As-Is BOT</p>

</body>

You have to write your html text file like this and then in code session
1.)first read the this text file and save it one string variable let say : email_body
2.)take one assign activity email_body = String.Format(email_body,DateTime.Now.ToString,dtSystemExceptions.Rows.Count.ToString)
3.)after the email_body added , and then add values how many dynamic values that you need to pass ley say in your text file you add {0} , {1} then after email_body place , and then give two values

1 Like

I understand this now. Thank you so much!!

@kalyanDev Would you please review my code and let me know why when I run the workflow, the same line from excel is being placed in each email. I used the assign activity in the for each row activity, but it is only pulling from the first row of data in excel for all emails.
Main.xaml (9.9 KB)

I’ll check and I’ll update

@kalyanDev thank you-much appreciated!

Hi , Can you please share text file so that can test easily

@kalyanDev see the attached screenshot as I am unable to upload a txt file

Also, attached is the excel file where I am looking for it to pull the relevant details for each candidate so that each person gets a personalized email with the date, time, etc of their interview. Thank you for all the help with this!
List of Emails to Send.xlsx (8.7 KB)

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