Adding and Formatting Tables inside Emails

For one of my projects, I need to send a report in mail as a table which I included in my mail as a HTML table. I still need to reduce the column size of the table as whatever table I attach its size remains the same. I don’t need a big table for just 2 or 3 columns. The steps I followed are;

  1. Create a text file as mail template using HTML Tags and variable fields. ({0},{1})
  2. Convert the required data table into HTML table using activity (Data Table To Html Table)
  3. Attach the HTML table to the body of the mail, in the variable field. (say, {0})

This method gives me only a specific table size which I couldn’t alter.
Kindly help me out to change the size of the table. Should I follow a different way?

Thanks in advance,
Fenelein George.

Hi @Fenelein

I’m not sure whether this is the normal way that people use. However, when formatting emails, I use a online html editor to get the format as a HTML code. There, I have created tables just like what you need and I have adjusted the column sizes and stuff like that. The code automatically generates in the site. Then what I do is, after everything is done, I get the code and copy it to a text file and save it. In the send mail activity, for the body, I mention the text I have in the text file in HTML format. This is the best approach that I have tried out and it works perfect for me.

Below is the site I use,

Check the below sample code I created for a table with different column widths.

<table style="width: 370px; height: 143px;">
<tbody>
<tr>
<td style="width: 124.233px;">Column 1</td>
<td style="width: 150.317px;">Column 2</td>
<td style="width: 73.45px;">Column 3</td>
</tr>
<tr>
<td style="width: 124.233px;">Data</td>
<td style="width: 150.317px;">Data</td>
<td style="width: 73.45px;">1</td>
</tr>
<tr>
<td style="width: 124.233px;">D</td>
<td style="width: 150.317px;">D</td>
<td style="width: 73.45px;">2</td>
</tr>
<tr>
<td style="width: 124.233px;">D</td>
<td style="width: 150.317px;">D</td>
<td style="width: 73.45px;">3</td>
</tr>
<tr>
<td style="width: 124.233px;">D</td>
<td style="width: 150.317px;">D</td>
<td style="width: 73.45px;">4</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>

Let know whether this helps to get your problem sorted

1 Like

Hi @Lahiru.Fernando,

I understand this and this seems to be a static table. Kindly let me know how I can display a DataTable that has dynamic values for each run.

Try this :slight_smile: Datatable to HTML

It allows you to convert a dynamic datatable to html format and also allows for some formatting changes.

2 Likes

Hi @TimK,

Thanks. I’m using the same activity. The only concern is that I need to fix the table size which I couldn’t do with this activity.

Hi @Fenelein

I think @TimK suggestion would suit your requirement :slight_smile:

Hi @Lahiru.Fernando

I used the same activity to convert the Datatable to Html and added to the mail. But the issue is, the table that I get in the mail has a much bigger size than needed. How can I define the table size?

If the datatable you originally have it too big , i.e. too many columns. You can remove extra columns using Remove Data Column, if you know the columns as the table in the original question.

You can use a for each loop using the column names and if it is not in the list that you want to keep, remove it.

Hi, @TimK,
Its not about the Number of columns.

If you see this sample, I don’t want the COLUMN SIZE of each columns to be this bigger. How can I define the SIZE of the table?

You mean the actual width of the table within the HTML?

I haven’t played around with it that much but if there isnt anything within the activity.

You many need to amend the html to reduce the table with using Inline CSS

Yes that is what I’m looking for.
If you can kindly suggest a possible inline CSS sample for the dynamic Datatables.