Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[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?
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,
You can pass query result to Context value then send them by tsendmail.
Please have a look at my screenshots.
Best regards
Sabrina
0683p000009MDvw.png 0683p000009ME36.png 0683p000009ME7q.png

View solution in original post

6 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

Thanks Vaibhav
Can you give me the URL of largo's post?
Anonymous
Not applicable
Author

Hi,
You can pass query result to Context value then send them by tsendmail.
Please have a look at my screenshots.
Best regards
Sabrina
0683p000009MDvw.png 0683p000009ME36.png 0683p000009ME7q.png
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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

You can write the HTML in to text files, use the context variables to update the text file, then import the text file as a global variable (string) eventually calling the global variable into the body of your email.