How to send text in table format in mail body

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