How To send outlook email including the name from an excel DataTable as the body

Hi All, I am sending an outlook mail message but I have an excel file where I’ll collect the name from the row and include in the mail body. Example the mail body will begin with
Dear Nebu,
from an excel sheet having this names:
First Name


@RPA-botDev do you want work for all names similarly or only one particular name from the excel.


— use excel application scope and pass the file path of excel as input
— use read range and get the output with a variable of type datatable named outdt
— use a for each row loop and pass the above variable as input
— mean while create a list variable named outlist in the variable panel of type system.collections.generic.list(of string) with default value as new list (of string) defined in the variable panel
— now inside the for each row loop use a add to collection activity and in item property mention as row(“Yourcolumnname”).ToString and in collection mention as outlist and type argument as string
— outside the for each row loop use a assign activity like this
Outvalue = String.Join(outlist.ToArray(),Environment.NewLine)

Where outvalue is a variable me of type string
—now create a text file (.txt file) and put this inside

Dear Nebu,
from an excel sheet having this names:
First Name

—save it as intext.txt
— now use a read text activity next to the above assign activity and read the file intext.txt and get the Output as a string variable named bodytext of type string
— now use a send outlook mail activity and mention the to and subject
While coming to body
Mention as string.Format(bodytext,outvalue)

Here bodytext is the variable obtained on reading the text file which has a place holder {0} where the value of the variable outvalue will be placed with this string.Format method

Simple isnt it
Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @RPA-botDev


Hi Palaniyappan, I have an error in the assign OutValue = String.Join(outlist.ToArray(),Environment.NewLine) that 1 dimensional array of string cannot be converted to string

1 Like

Are you there?

1 Like

Sorry for the Delay
Aaha sorry the assign should be like this
Outvalue = String.Join(Environment.Newline,outlist.ToArray())

Typo mistake
Cheers @RPA-botDev

1 Like

so were we able to accomplish @RPA-botDev
any other issues to be discussed

Yea, that’s cool, I run the workflow and the email sent all the names but I need only the name in the first row, how do I achieve that?

well if we want to send for first row alone
add a break atlast of the for each row loop
so that it will break once the first iteration is done
Cheers @RPA-botDev

1 Like

Cheers @Palaniyappan it worked, I have another question though

1 Like

yes tell me


I want the bot to check if there is an incoming email that has the subject awaiting, it will log into a site and perform action, if also there is an incoming email with subject rejected, it will log into a site also and perform action but the problem is that it performs the action on the same in the site if either awaiting or rejected. Is there a way I can make it stop action if one is performed. I.e If subject contains awaiting log in and change position else if subject contains rejected and position changed don’t change the position. Something like that

Hi there?

Hi @RPA-botDev

Is there a way I can make the bot not perform action if an action has been performed already on the site?

of course its possible
–if any element or image appears once a set of action is performed we can find it with on Element appears or on image appears , where the output will be a boolean
–we can use a if condition and check if true will go for THEN part whee we can stop the process or if not continue in ELSE part
–to stop the process either we can Throw activity to throw an exception in the THEN part of if condition, so that bot will get stopped

Cheers @RPA-botDev

1 Like

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