Send email with excel fields in body

Hi @Francisco_Morales

That’s a good question and is very simple to handle
— keep the body of the mail In text file
— use read text file activity and pass the file path that text file and get the output in a variable of type string named body_Text
—use a excel application scope and pass the file path as input
—use read range activity and get the output in a variable of type datatable
—use a for each row loop and pass the above variable as input and inside this use assign activity and get the values of each row and each column to variable like this
Out_value1 = row(“yourcolumn1name”)
Out_value2 = row(“yourcolumn2name”)
…similarly for all the columns
—next to this for each row loop, use a send outlook mail or send exchange mail activity and mention the To property,subject property and finally the body of the mail with the variable as body_Text of type string
— but the thing we need to keep in mind is how we are going to pass this text string as a template ands other values from the excel
— inside the text file keep a template like this with the place holders where the above for each row loop variables and it’s values are going to be passed to the template ( I m mentioning in English with a sample template in a .txt file)

Hi {0},

Good morning
Invoice number {1}
Quantity {2}

Bye {3}

Here {0},{1},{2},{3} are place holders and as the name implies it will take the value passed to it…HOW…?
— yes using string format method
While I mentioned that to mention the body in send outlook mail activity, it should be like this
**String.Format(body_Text,Out_value1,Out_value2,Out_value3,…)

So the values from these variables will be filled in order one by one in the place holders in the text {0},{1},…

Simple isn’t it
Cheers @Francisco_Morales

5 Likes