How to display the contents of a table into HTML mailbody?

Highlighted
Five Stars

How to display the contents of a table into HTML mailbody?

Hi Guys,

 

I am trying a scenario where I am running an Oracle SP and exporting the data from a table into html format in email. Please guide me how should I approach this.

 

I already did a Mapping like below and able to extract the data into Excel and send email with the attachment.

 

tOracleSP  --------> tOracleInput---------->tFileOutputExcel------------>tsendmail

 

              

1) Can I export the data from Excel into html format and send mail?

2) Can I export the data directly from table (instead of tFileOutputExcel) and send email in HTML format ?

 

Your suggestions are highly appreciated !!

 

Thanks,

Sekar

Sixteen Stars TRF
Sixteen Stars

Re: How to display the contents of a table into HTML mailbody?

Select HTML for the mime type and construct the HTML using a tJavaRow to populate a global or context variable to be reused as the message body.
You may refer to this post https://community.talend.com/t5/Design-and-Development/How-to-inject-html-code-into-message-of-tSend...

TRF
Sixteen Stars TRF
Sixteen Stars

Re: How to display the contents of a table into HTML mailbody?

Did this help?
If so, thank's to mark your case as solved (Kudos also accepted).

TRF
Five Stars

Re: How to display the contents of a table into HTML mailbody?

Hi,

 

I have been trying with the below approach but not getting the data in proper email format . Could you please help !!

Design.JPG

 

 

 rOracleDBInput:

SELECT
'<tr><td>'||TABLE_NAME.KEY_NUMBER||'</td>'
||'<td>'||TABLE_NAME.TBL_NAME||'</td>'
||'<td>'||TABLE_NAME.SCHEMA_1_COUNT||'</td>'
||'<td>'||TABLE_NAME.SCHEMA_2_COUNT||'</td>'
||'<td>'||TABLE_NAME.COUNT_DIFFERENCE||'</td>'
||'<td>'||TABLE_NAME.UPDATED_TIME||'</td></tr>'
FROM TABLE_NAME;

 

tJavaRow:

context.email = context.email + "<tr><td>" + input_row.KEY_NUMBER + "</td><td>" + input_row.TBL_NAME + "</td><td>" + input_row.SCHEMA_1_COUNT+ "</td><td>" + input_row.SHEMA_2_COUNT + "</td><td>" + input_row.COUNT_DIFFERENCE + "</td><td>" + input_row.UPDATED_TIME+"" + "</td></tr>" ;

 

 

 

tSendmail:

 

"<head><meta http-equiv=Content-Type content=text/html;
charset=iso-8859-15><style type=text/css>table,TD, TH{
white-space: nowrap;
border:1px solid CornflowerGreen ;
font-size:12px;
font-family: Arial;
}
th{
white-space:nowrap;
background-color:CornflowerGreen;
color:Black;
}
<style><head>Hi Team<p><table><th>KEY_NUMBER</th><th>
<TBL_NAME/th><th>SCHEMA_1_COUNT</th><th>SCHEMA_2_COUNT</th><th>COUNT_DIFFERENCE</th><th>UPDATED_TIME</th><tr>"+context.email+"</tr></table>"

 

I am getting only the Headers in the table. Could anyone guide me to get the table data as well.

 

HTML_Mail.JPG

 

tABLE_fORMAT.JPG

I will have more than 50 rows in table and the count will vary. What would be the best possible solution to get the data in HTML format thru 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

Talend Cloud Developer Series – Defining Metadata

This video focuses on different methods of adding metadata to a job in Talend Cloud

Watch Now

Talend Cloud Developer Series – Updating Context Variables

This video will show you how to add context parameters to a job in Talend Cloud

Watch Now

Talend Cloud Developer Series – Deploying First Job to Cloud

This video will show you how to run a job in Studio and then publish that job to Talend Cloud

Watch Now