[resolved] Sending query result by mail

Highlighted
Eight Stars

[resolved] Sending query result by mail

Hi all,
This is more of a designing question than related to the tool.
I have a SQL query whose output I need to write in a message and send it using the tSendMail component.
Anyone has done something similar or can tell me how I can design this job ?
One job design that comes to my mind is:
tMysqlInput---row1 (Main)--->tMap---sql_data (Main)--->tFileOutDelimited
But then I get stuck.
I don't understand how I can read the contents of this delimited file and write it into the mail body.
Can anyone help me please?

Accepted Solutions
Moderator

Re: [resolved] Sending query result by mail

Hi,
You can pass query result to Context value then send them by tsendmail.
Please have a look at my screenshots.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

All Replies
Four Stars

Re: [resolved] Sending query result by mail

Use following
tMysqlInput---row1 (Main)--->tJavaRow-->OnSubJobOk-->tPop
in tJavaRow read every row and write formatted data in the form of html to context variable
Use that context variable inside the body of mail.
Check the post by largo-- he used html template for composing message
you will get some idea from this.
Thanks
Vaibhav
Eight Stars

Re: [resolved] Sending query result by mail

Thanks Vaibhav
Can you give me the URL of largo's post?
Moderator

Re: [resolved] Sending query result by mail

Hi,
You can pass query result to Context value then send them by tsendmail.
Please have a look at my screenshots.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Eight Stars

Re: [resolved] Sending query result by mail

Thanks xdshi!
That helped a lot.
But I want to format the text into HTML.
If I write the following in the tJavaRow component:
context.messageVariable = context.messageVariable+"<tr><td>"+row1.column1+"</td><td>"+row1.column2+"</td></tr>"

and in the tSendMail's Message field I write:
"<html><body><table>"+context.messageVariable+"</table></body></html>"

The text in the mail appears as
<html><body><table><tr><td>value1.1</td><td>value2.1</td></tr><tr><td>value1.2</td><td>value2.2</td></tr></table></body></html>
Is it possible to format the mail as a HTML content mail
Eight Stars

Re: [resolved] Sending query result by mail

I got how to change the content type from largouwalid's post.
Thanks again vaibhav and xdshi for all your help!!

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

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now