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!

1 ACCEPTED SOLUTION

Accepted Solutions
Forteen Stars TRF
Forteen 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
3 REPLIES
Forteen Stars TRF
Forteen 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?
Forteen Stars TRF
Forteen 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