Post HTML email with datatable but doesn't contain header

Hello,

I’m currently creating an email with an HTML body table. The email has been successfully created, but the output table does not have a header, how do i set it, so that the header appears in the table. By the way, I created the HTML syntax through the “Create HTML Content” activity. i appreciate for any help. Thank you.


1 Like

Hi,

As a workaround, can you try as the following?

dr = dt.NewRow
dr.ItemArray = dt.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).ToArray

Then call dt.Rows.InsertAt(dr,0) using InvokeMethod activity

note: This assume all the column type are string or object.

Regards,

1 Like

@Yoichi it means we add a row containing the header name manually in the datatable that we want to print, isn’t it?

Hi,

Yes. And it requires the above assumption : column type is string or object.

Regards,

Ok, i get it. But what is the contents of the dr.ItemArray variable. I mean, does the variable dr.ItemArray automatically contain the header name when using this syntax. I do not exactly understand what this syntax means. Could u please give me a little bit explanation. Thank u so much

dr.ItemArray = dt.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).ToArray

You can refer to this How to pass datatable to html with headers

Basically you will need to output your datatable to string(csv), then read it back to datatable without useRowHeader.

3 Likes

Hi,

We can set items of the datarow using dr.ItemArray

And

dt.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).ToArray

is LINQ expression to create column name array. More specific,

dr.Columns returns ColumnCollection and Cast converts it to IEnumerable<DataColumn> for able to handle by LINQ.

Select(Function(dc) dc.ColumnName).ToArray

returns ColumnName array from IEnumerable<DataColumn> instance.

As a result, items of the datarow are set the column name string.

Regards,

@Yoichi thank you so much for the complete explanation. very helpful :+1:

1 Like

@yi.ying.lee , Wow, that’s a much faster way. Thanks so much :+1:

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