how to create a HTML-Table in Email with input of Database query

Highlighted
Four Stars

how to create a HTML-Table in Email with input of Database query

i have a query on a Database which give me Infomation like this: enter image description here

i want to create a HTML Table with Information of the query above and send it to Email of Developer as Error Notification. Can you help me with the HTML code?. Thankyou alot!


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: how to create a HTML-Table in Email with input of Database query

As a strating point you case copy/paste the following piece of Java code into a tJavaRow connected to to your data flow (for ex. tOracleInpput-->tJavaRow).

String msg = ((String)globalMap.getOrDefault("mailMessage", "<TABLE border=0 cellspacing=1px>" + "<TR><TD>ID</TD><TD>Error</TD><TD>Date</TD></TR>"));
msg = msg + "<TR><TD>" + row1.ID + "</TD><TD>" + row1.Error + "</TD><TD>" + row1.Date + "</TD></TR>"
globalMap.put("mailMessage", msg);

When the subjob is finish (onSubjobOK), a tSendMail will send the email using the content of the global variable "mailMessage" as as the message using the following syntax:

((String)globalMap.get("mailMessage"))

You can enrich the table with colors and so on. 


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: how to create a HTML-Table in Email with input of Database query

As a strating point you case copy/paste the following piece of Java code into a tJavaRow connected to to your data flow (for ex. tOracleInpput-->tJavaRow).

String msg = ((String)globalMap.getOrDefault("mailMessage", "<TABLE border=0 cellspacing=1px>" + "<TR><TD>ID</TD><TD>Error</TD><TD>Date</TD></TR>"));
msg = msg + "<TR><TD>" + row1.ID + "</TD><TD>" + row1.Error + "</TD><TD>" + row1.Date + "</TD></TR>"
globalMap.put("mailMessage", msg);

When the subjob is finish (onSubjobOK), a tSendMail will send the email using the content of the global variable "mailMessage" as as the message using the following syntax:

((String)globalMap.get("mailMessage"))

You can enrich the table with colors and so on. 


TRF
Four Stars

Re: how to create a HTML-Table in Email with input of Database query

Thankyou very much, it worked for me.
Can you please show me how to format it like a table?with border line?
Fifteen Stars TRF
Fifteen Stars

Re: how to create a HTML-Table in Email with input of Database query

Great!

For the rest, this is a HTML question, not a Talend one.

However, have a look at "TABLE border" parameter.


TRF
Two Stars

Re: how to send a table to email body through talend

Hi,
I Tried to to develop a job through talend using the below java code.  But i face the below issuesSnipImage.JPGCapture.PNG 

 

Can you please help me to know the configuration of  tJavaRow and tSendMail

 

 

What’s New for Talend Spring ’19

Join us live for a sneak peek!

Sign up now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download