DataTable to Html and send as body through mail

Hi All,

I have excel file which has a dataTable and i wnat to convert it to html and then send it as a body through mail.

for that i got code from google, but it has some error it seems, i am pasting the code for your refrence.

But on line 6 and 19 , it says HTTPUtility is not the member of System.Web

How to resolve it? since i have no idea to fix it and also let me if there is another way of doing that.

Thanks in Advance


You can use this snippet to convert datatable to HTML.
DataTable_To_HTML.xaml (9.8 KB)

Hope this might help you.


For the conversion of Datatable to HTML Table, You could also refer to the below post :

Hi @supermanPunch ,

i just copied the code from above, but it has one activity error.



Just copy the part after equals (=), The variable before (=) should be in the L.H.S of the Assign Activity and the value after (=) should be in the R.H.S

yes, it’s very nice.

so it will convert any number of columns of Datatable?

and also if possible , since tags are bit confusing ,not able to understand what is happening actually, can you pls explain?


For details on the What is HTML Table and what are the tags in it, you could check the below link :

Now, In the Expression the First Part is below :

"<table border=2><b><tr><td>"+String.Join("</td><td>",TestDt.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName).ToArray)+"</td></tr></b>"+

This is used to create the Headers/Column Names in the HTML table. It fetches the Column Names from the datatable and formats it in the required format as needed to convert to HTML Table columns.

The Next part, we are performing the same as that of the above Expression, but here we are fetching the data/values present in the Datatable and formatting it as required for the HTML Table Structure.

String.Join("</tr><tr>",(From x In TestDt.AsEnumerable
Let cells="<td>"+String.Join("</td><td>",x.ItemArray)+"</td>"
Select cells).ToArray)+"</tr>"

The w3Schools link should help you on the info related to tags.

1 Like

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