Add Table data in Email Body


I have an Excel that has 20+ Columns but I need to fetch data corresponding to only 4 columns Name along with headers , I tried creating a file and putting html code using TR TD , TH
But how to give specific column name to be added in file


I added this code but this will append all the column names in file I want only column name: a , d , j and s to be added .

Please suggest


You can get columns using index as well.

Append line - String.Format("<th>{0}</th>",DT_filter_Columns.columns(1).ColumnName.tostring)
Append line - String.Format("<th>{0}</th>",DT_filter_Columns.columns(2).ColumnName.tostring)
Append line - String.Format("<th>{0}</th>",DT_filter_Columns.columns(3).ColumnName.tostring)
Append line - String.Format("<th>{0}</th>",DT_filter_Columns.columns(4).ColumnName.tostring)

Where can i add the column Name ?
Append line - String.Format("<th>{0}</th>",DT_filter_Columns.columns(1).ColumnName.tostring)

Should I replace ColumnName with the name of my desired Coulumn from Data table ?


Here “1” is the index of your column. This will give you the 1st column in the table.

Since you need the first 4 columns, we can go with the index only to get your desired column. No need to mention Column name.

how to add email metadata into datatable
datatable columns : subject(String), body(String), attachmentName(String)