Page 1 of 1

Query result in Email Body

Posted: Thu Aug 16, 2018 12:40 pm
by atulgoel
Hi,

How to send output of Query Result in the email body using datastage.

Example: I write the output of a query in a text file. Then content of text file or directly output of query, I want to send in Email Body

Thanks
Atul

Posted: Thu Aug 16, 2018 2:04 pm
by chulett
Unless something has changed in the newer versions (and it looks like it hasn't) the Notification Activity stage only supports files as attachments. However, that doesn't mean you can't do a couple of other things to get the results you want.

1) Write your own custom version of the existing DSSendMail routine and add that functionality, then use that routine to send email from a Sequence job rather than using the Notification Activity stage.

2) Write a script to send mail from the server using whatever mail software you have installed (sendmail, mailx, whatever) and build in that ability, then leverage the script via the Execute Command stage in a Sequence job or 'After Job' or wherever you like.

Both would take the filename containing the text to inline / inject into the email body as a parameter / argument.

Posted: Fri Aug 17, 2018 2:39 pm
by atulgoel
Thanks for the reply. Is it possible to share the sample routine which can send the output of text file in Email body.

Posted: Fri Aug 17, 2018 3:02 pm
by atulgoel
I tried below in DSSendMail routine. Its sending email, but its not sending the content of file in email body

"From:atul@xxxxxx.com\nTo:atul@xxxxxx.com\nSubject:Hi ya\nAttach:/app/bb5g_etl/ATUL/email.txt\nBody:\n Execute_Command_1.$CommandOutput"

Posted: Fri Aug 17, 2018 3:09 pm
by atulgoel
Its working now. I used DSSendMailTester inbuilt routine.

Posted: Fri Aug 17, 2018 5:02 pm
by chulett
Hopefully you made of copy of it first and are using the copy with a more appropriate name.