How to send text in table format in mail body

Hi I have 3 strings need to add header
checkpoint status comments
& add that 3 string values in these 3 columns(checkpoint status comments)
as a table format in mail body.
Please help

Hi @vnsatyasunil ,
I understand you need add a table have 3 columns to body email
That’s right?
If it’s right. You can create body email as HTML format.
https://docs.uipath.com/activities/other/latest/productivity/create-html-content
Regards,
LNV

Use create html content

1 Like

ok thanks. Can we use create html content output variable in mail body and send mail

Activity:Create html Content
You will have an option of insert table! in property panel set the output variable.
Once its done write the output variable in body of the mail

1 Like

You will have an option of insert table! in property panel set the output variable.
Once its done write the output variable in body of the mail

1 Like

Yes, You can create variable output

ok will try it Thanks

1 Like

Hey @vnsatyasunil , You can build datatable with the 3 columns using Build datatable activity
Populate the datatable with required fields

After that there are 2 Solutions

Method 1: Using Create HTML Content activity
If you want to go through this activity directly then you wont be getting the headers
so if you want column headers , write the datatable back to excel and then again read the workbook with ADD HEADERS Option Unticked

After that send that Datatable to Create HTML Content and it will work!

Method 2: You can use Linq query which will convert your datatable into html content directly
Please find the Linq code below

"<table border=2><tr><td>"+String.Join("</td><td>",YourDT.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName).ToArray)+"</td></tr>"+
"<tr>"+String.Join("</tr><tr>",(From x In YourDT.AsEnumerable
Let cells="<td>"+String.Join("</td><td>",x.ItemArray)+"</td>"
Select cells).ToArray)+"</tr>"

Replace YourDT with your Datatable in the above code

Hope it helps you !

5 Likes

This solution works, thanks !

1 Like

This works! It is the easiest way to include/implement structured data’s (like datatables) in a mail body.

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