multiple html tables in email

Highlighted
Seven Stars

multiple html tables in email

I am able to send html based email  that contains one single table via tsendemail. I have another table for record counts that I would like to send in the same email.

 

I have created two mail messages and here is what my tsendemail looks like:

"Results are : \n" + ((String)globalMap.get("mailMessage")) + "\n Record Counts : \n" + ((String)globalMap.get("mailMessage_two"))

 

However the second email message is getting appended to the last cell of the first table instead of a separate table.

 

here is tJavaRow_1:

String msg = ((String)globalMap.getOrDefault("mailMessage", "<TABLE name=b border=1 cellspacing=1px>" + "<TR><TD>STEP</TD><TD>DATETIME</TD></TR>"));
msg = msg + "<TR><TD>" + input_row.Step + "</TD><TD>" + input_row.Timestamp + "</TD></TR>";
globalMap.put("mailMessage", msg);

 

tJavaRow_2:

String msg_two = ((String)globalMap.getOrDefault("mailMessage_two", "<TABLE name=a border=1 cellspacing=1px>" + "<TR><TD>S</TD><TD>D</TD></TR>"));
msg_two = msg_two + "<TR><TD>" + row4.Timestamp + "</TD><TD>" + row4.Label + "</TD></TR>";
globalMap.put("mailMessage_two", msg_two);

 

 

I have attached a screenshot of the flow.tsendemail.PNG

 

Here is the resulting email at the moment:

tsendemail_result.PNG

Any thoughts on how can I get the second table to print out separately?

 

 

Thanks


Accepted Solutions
Seven Stars

Re: multiple html tables in email

That did not work.

 

However I was able to make it work by adding </Table> within tsendmail message body.

 

"Results are : \n" + ((String)globalMap.get("mailMessage")) + "</TABLE>" + "\n" + "\n" + "Record Counts : \n" + ((String)globalMap.get("mailMessage_two"))

 

Thanks for the idea. It was helpful.


All Replies
Nine Stars

Re: multiple html tables in email

This is not a Talend question at all but an HTML question, but I will answer it anyway.

 

You need an end table tag after the first message.  You should put one after the second message too for best practice.

 

...
input_row.Timestamp + "</TD></TR></table>";
globalMap.put("mailMessage", msg);
...
msg_two = msg_two + "<TR><TD>" + row4.Timestamp + "</TD><TD>" + row4.Label + "</TD></TR></table>";
...
--
Please give Kudos and mark topics as solved where appropriate.
Seven Stars

Re: multiple html tables in email

That did not work.

 

However I was able to make it work by adding </Table> within tsendmail message body.

 

"Results are : \n" + ((String)globalMap.get("mailMessage")) + "</TABLE>" + "\n" + "\n" + "Record Counts : \n" + ((String)globalMap.get("mailMessage_two"))

 

Thanks for the idea. It was helpful.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog