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

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
Sixteen Stars TRF
Sixteen 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

View solution in original post


All Replies
Sixteen Stars TRF
Sixteen 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

View solution in original post

Highlighted
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?
Sixteen Stars TRF
Sixteen 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

 

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog