Query result in Email Body

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
atulgoel
Participant
Posts: 84
Joined: Tue Feb 03, 2009 1:09 am
Location: Bangalore, India

Query result in Email Body

Post 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
Atul
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
atulgoel
Participant
Posts: 84
Joined: Tue Feb 03, 2009 1:09 am
Location: Bangalore, India

Post 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.
Atul
atulgoel
Participant
Posts: 84
Joined: Tue Feb 03, 2009 1:09 am
Location: Bangalore, India

Post 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"
Atul
atulgoel
Participant
Posts: 84
Joined: Tue Feb 03, 2009 1:09 am
Location: Bangalore, India

Post by atulgoel »

Its working now. I used DSSendMailTester inbuilt routine.
Atul
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hopefully you made of copy of it first and are using the copy with a more appropriate name.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply