How to customise the body of send smtp mail activity according to CSV status column

Hey Guys ,

The mail which we are sending at the last , can we modify the body of the mail . I mean, I want to show the OEM Names in the body of the mail if the status for them is FAIL

This is the CSV that is generating after all the process is completed -

Now I want to display Audi and Ducati in the body of the mail



1 Like

Hey rishabhverma,

I approached with the following steps:

  1. Load the csv in to UiPath (as a DataTable)
  2. Filter for “Status” = “Fail”
  3. Get a list of the “OEM” in this filter
  4. Join all results together to insert in to a sentence

With the following you can use some LINQ to query for “Fail” statuses and save the resulting OEM values to a List(Of String):

List(Of String) = dt.AsEnumerable.Where(Function(rows) rows.Field(Of String)("Status") = "Fail").Select(Function(rows) rows.Field(Of String)("OEM")).Distinct.ToList

Note I have added a “.Distinct” to avoid duplicates. You may want to remove this depending on your use case.


Look at String.Join to include the results in your email body.

Please also consider replacing hard coded column names with config values :slight_smile:

1 Like

How you would like to add along the mail
As a table or just a string/sentence along the mail body

If you want to send the mail body with those values as sentence then once after getting value we want as @cshan suggested, you can pass that like this
—let’s take like you have the body message stored as a string in a variable named str_body
—now use string.Format method to add those values along the body mail
That is along the body string use a {0}, and put this place holder in the place where you want to add the values
—then I’m studio with a assign activity
str_body = str_body.String.Format(“{0}”,String.Join(“-“,yourvalue.ToArray())).ToString

Where yourvalue is the list variable that you have with the values you filtered

Cheers @rishabhverma

1 Like