Add Table as HTML code

Hello, I have got a queer automation request. Please, see whether below proposed solution theoretically can be used, any suggestions of easier ways to front this task are very welcomed.

Here’s the actual challenge - it is required to send an email with a body in which there should be a table. That table’s number of rows can vary from one case to another.

I thought it’d be nice to make html-based layout for an email.

So, I have this HTML code

"<!DOCTYPE html>
<html>
<style>
table, th, td {
  border:1px solid black;
}
</style>
<body>


<table style="width:100%">
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>dtTemp.Rows(0).Item(1).tostring</td>
    <td>dtTemp.Rows(0).Item(2).tostring</td>
    <td>dtTemp.Rows(0).Item(3).tostring</td>
  
  </tr>
  <tr>
    <td>dtTemp.Rows(1).Item(1).tostring</td>
    <td>dtTemp.Rows(2).Item(2).tostring</td>
    <td>dtTemp.Rows(3).Item(3).tostring</td>
   </tr>
</table>

</body>
</html>

When I know that there will be N number of rows, I should add this to the table if I’d like to have a new line

<tr>
    <td>dtTemp.Rows(N).Item(1).tostring</td>
    <td>dtTemp.Rows(N).Item(2).tostring</td>
    <td>dtTemp.Rows(N).Item(3).tostring</td>
  
  </tr>

Please, can you tell me how to achieve that result, maybe by using for each row and replacing the dynamic part with variable with a string to which text gets appended, or something easier?

Thank you

@ykuzin

Can you share a sample Excel file and also sample email to look like

So that we can try

For reference, check below

Hope this will help you

Thanks

1 Like

Hi @Srini84

It is a raw coma separated uipath data table that looks like this:

Column1,Column2, Column3
name,01/01/01, 1345.35
name1,02/02/02,123.12

Will it be sufficient enough?

we can read in CSV data into datatable.
the it is similar as mentioned above

1 Like

@ykuzin

Use Read CSV activity to read into the datatable

Now using For Each Row activity you loop into the datatable

Later you can follow the steps in the post

Hope this will help you

Thanks

1 Like

@ppr @Srini84

as per Edit HTML Content activity of the Mail package 1.10.4 I am limited in defying the number rows, which should be more than 3.

How this solution can be used, when there are more rows?

Hi @ykuzin

Refer to the thread below!

Regards

1 Like

have a look on the mentioned activity:

1 Like

Hi, thanks for the useful reference, did you have a similar situation in which the first row is highlighted in bold? I can’t have HTML editor to build the datatable in general font, because it treats the first row as a header. All I have is Data table referenced that way {{Data Table}} in HTML editor .

Use Package 「Datatable To HtmlTable String」 by Maninder Singhis a easy way to achive this.
this activity have some simple function to handle the table color.
check below