Send query result by mail

Highlighted
Seven Stars

Send query result by mail

Using what is described in following link:

https://community.talend.com/t5/Design-and-Development/resolved-Sending-query-result-by-mail/m-p/100...

 

I am able to send the query results by email but the email is print results column after column and not in row.

By that I mean if my table looks like this:

 

Name   Date

John     05-08-2019

Nas      05-07-2019

 

The email that I get is this:

Name:

John

Nas

Date:

05-08-2019

05-07-2019

 

This is what I have in tjavarow:

context.StepName = context.Name+"\n"+input_row.Name;
context.Timestamp = context.Timestamp+"\n"+input_row.Timestamp;

 

And this is how the email message in tsendMail is composed:

"Name: "+context.StepName+ " Date:" + context.Timestamp+"."

 

What I would like to see in the result is each row with column header:

 

Name   Date

John     05-08-2019

Nas      05-07-2019

 

How can I accomplish this?

talend_mail.PNG

Thanks

Tags (1)

Accepted Solutions
Employee

Re: Send query result by mail

Hi,

 

    Your email component is called after tjavarow data processing using on SubJob Ok.

 

So the context.StepName is havig data as below

 

Name:
John
Nas

   since you have given the code as shown below. It means, the data of name will get continously accumulated to the StepName column one after another.

   context.StepName = context.Name+"\n"+input_row.Name;

 

   Instead of this, you can do a simple trick.

 

Assign the initial value of context.Step as shown below.

 

context.Step="Name"+"\t"+"Date";

Inside tjavarow, add as below.

 

context.Step= context.Step+"\n"+input_row.Name+"\t"+input_row.Timestamp;

Then, use the context.Step inside your existing tSendmail (which is connected using OnSubJobOk). This should reslve your issue :-)

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 

 

 

 

    


All Replies
Employee

Re: Send query result by mail

Hi,

 

    Your email component is called after tjavarow data processing using on SubJob Ok.

 

So the context.StepName is havig data as below

 

Name:
John
Nas

   since you have given the code as shown below. It means, the data of name will get continously accumulated to the StepName column one after another.

   context.StepName = context.Name+"\n"+input_row.Name;

 

   Instead of this, you can do a simple trick.

 

Assign the initial value of context.Step as shown below.

 

context.Step="Name"+"\t"+"Date";

Inside tjavarow, add as below.

 

context.Step= context.Step+"\n"+input_row.Name+"\t"+input_row.Timestamp;

Then, use the context.Step inside your existing tSendmail (which is connected using OnSubJobOk). This should reslve your issue :-)

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 

 

 

 

    

Seven Stars

Re: Send query result by mail

That worked.

 

Thanks for your help.

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads