Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
stellayou33
Contributor
Contributor

How to add a customized table in sending email with html/java code?

Hi, I'm facing a problem with creating a customized table in the email part of my data alert. I want to get the row counts of two tables in different servers and generate a table basically looks like the picture below.

0693p00000C7s5jAAB.png

But I only received an email with a bunch of code in my email:

<HTML><HEAD><style type="text/css">.TFtable{width:100%; border-collapse:collapse; }.TFtable td{ padding:7px; border:# 4e95f4 1px solid; width:10%; text-align: center;}.TFtable tr{ background:# b8d1f3; width:100%; }.TFtable tr:nth-child(odd){ background: # FFFF;}.TFtable tr:nth-child(even){ background: # 8080ff; }.TFtable th{background: # 00001a;width:15%; text-align: center; padding;25%; color: white;}</style></HEAD><BODY><h3 style='text-align:center;'>Table</h3><table class="TFtable"><tr><th>Table1</th> <th>Count1</th><th>Table2</th><th>Count2</th><tr><tr><td>abc</td><td>123</td><td>def</td><td>456</td></tr></table>

My data pipeline looks like this:

0693p00000C7s8SAAR.png

The code in tJava_1:

globalMap.put("v_DetailedReport" , globalMap.get("v_DetailedReport").toString()+

"

<HTML><HEAD><style type="text/css">.TFtable{width:100%; border-collapse:collapse; }.TFtable td{ padding:7px; border:# 4e95f4 1px solid; width:10%; text-align: center;}.TFtable tr{ background:# b8d1f3; width:100%; }.TFtable tr:nth-child(odd){ background: # FFFF;}.TFtable tr:nth-child(even){ background: # 8080ff; }.TFtable th{background: # 00001a;width:15%; text-align: center; padding;25%; color: white;}</style></HEAD><BODY><h3 style='text-align:center;'>Table</h3><table class="TFtable"><tr><th>Table1</th> <th>Count1</th><th>Table2</th><th>Count2</th><tr>

"

);

tJava_2:

globalMap.put("v_DetailedReport" , globalMap.get("v_DetailedReport").toString()

+"<tr><td>"+globalMap.get("A").toString()

+"</td><td>"+globalMap.get("B").toString()

+"</td><td>"+globalMap.get("C").toString()

+"</td><td>"+globalMap.get("D").toString()

+"</td></tr>");

tJava_3:

globalMap.put("v_DetailedReport" ,

globalMap.get("v_DetailedReport").toString()+"</table>");

PS: A,B,C,D are the columns generated by the db input.

Anyone can help to debug this? Not sure the code doesn't map to a table. Thank you!

1 Reply
Alaor_Silva
Contributor
Contributor

Hi @Xiaoshan You​,

 

By the Resulting HTML code you sent, this is what you can expect to get in your email:

 

0693p00000C7zKaAAJ.pngTo validate the html you have a lot of options I just used https://www.w3schools.com/html/tryit.asp?filename=tryhtml_default

And on your tSendMail got to Advanced Settings and change it from Plan Text to HTML

 

0693p00000C7zMqAAJ.png 

I hope that helps you

 

Cheers