Unable to send Email

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Unable to send Email

Post by datastageETL »

Hi All,
I searched the forums related to this one but could not find a solution to my problem.

I have a parallel job retrieving reject records from a table in sql server to a file. I have an after job routine to email this file as an attachment after the retrieval is successful.

I am getting the following warning message

Test_Connection123..AfterJob (DSSendMail): The following tokens in the 'dssendmail_template.txt' file have not been set in the call to DSSendMail: %server%

The following is the code in my Afterjob Routine

Call DSLogInfo("Getting Reject File Information",DSJ.ME)

strDatapath = DSGetParamInfo(DSJ.ME, "$DATAPATH", DSJ.PARAMVALUE)
strRejectFileLoc = strDatapath:'\GenSys\Rejects'
strRejectFile = DSGetParamInfo(DSJ.ME, "JPM_SEQL_REJECT", DSJ.PARAMVALUE)

Call DSLogInfo("File":strRejectFile:" will be emailed to the client, if reject records exist",DSJ.ME)

*----Sending Mail to Business Users----*
FROM_MAILID = DSGetParamInfo(DSJ.ME, "JPM_FROM_MAILID", DSJ.PARAMVALUE)
TO_MAILID = DSGetParamInfo(DSJ.ME, "JPM_TO_MAILID", DSJ.PARAMVALUE)
Server_Name= DSGetParamInfo(DSJ.ME, "$MailServer", DSJ.PARAMVALUE)
ERROR_DIR = strRejectFileLoc
SUBJECT = "E-Mail Notification For Rejects"

If intNoRecReject >0 Then
Final_Attachment = ERROR_DIR:"\":strRejectFile
Result= DSSendMail("From:":FROM_MAILID:"\nTo:":TO_MAILID:"\nSubject:":SUBJECT:"\nAttach:":Final_Attachment:"\nBody:":"%report%":"\nServer:":Server_Name)
End

Any help is highly appreciated
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Try switching the position of 'Server' and 'Body' in the string you build, Body should be last AFAIK.
-craig

"You can never have too many knives" -- Logan Nine Fingers
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Post by datastageETL »

Thankyou Chulett. I will try that and will let you know if that solves the issue
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Post by datastageETL »

This change is treating the server information as part of the attachment as follows

Cannot open attachment file 'e:\data\dev\GenSys\Rejects\Reject1.csv \nServer:ndhamrexm05.amer.pfizer.com'

Any suggestions please
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Post your DSSendMail syntax again, please.
-craig

"You can never have too many knives" -- Logan Nine Fingers
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Post by datastageETL »

Here you go

If intNoRecReject >0 Then
Final_Attachment = ERROR_DIR:"\":strRejectFile
Result= DSSendMail("From:":FROM_MAILID:"\nTo:":TO_MAILID:"\nSubject:":SUBJECT:"\nAttach:":Final_Attachment:"\nBody:":"%report%":"\nServer:":ServerName)
End
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... I don't see any actual change. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Post by datastageETL »

Sorry, I got it wrong - let me send it to you again
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Post by datastageETL »

Here you go

Result= DSSendMail("From:":FROM_MAILID:"\nTo:":TO_MAILID:"\nSubject:":SUBJECT:"\nAttach:":Final_Attachment:"\nServer:":ServerName:"\nBody:":"%report%)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First problem is you have unmatched quotes:

"%report%)

Secondly, what is "%report%" supposed to be? Specifically questioning the use of the percent signs and finding nothing called 'report' in the code for the body of the email.
-craig

"You can never have too many knives" -- Logan Nine Fingers
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Post by datastageETL »

Craig,
I agree with you on the quotes - I got the error message during the compilation of the routine but forgot to make the change in my submission here.

%report% - looks like the default variable defined in datastage that provides the report that is being generated in my job.
FYI - My job consists of generating a flat file with the rejected records. This is being added as the content/attachment

The following shows that the CSV file is being retrieved by the use of this.

Test_Connection123..AfterJob (DSSendMail): Cannot open attachment file 'e:\data\dev\GenSys\Rejects\Reject1.csv \nServer:ndhamrexm05.amer.pfizer.com'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No, %report% is the token in the 'sendmail' script that gets generated, you need to pass an actual value there in your call. Build a 'body' string and reference it there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
datastageETL
Premium Member
Premium Member
Posts: 19
Joined: Tue Jul 28, 2009 1:53 pm

Post by datastageETL »

Thanks Craig. I will keep you updated.
siauchun84
Participant
Posts: 63
Joined: Mon Oct 20, 2008 12:01 am
Location: Malaysia

Post by siauchun84 »

Try this:
Result= DSSendMail("From:":FROM_MAILID:"\nTo:":TO_MAILID:"\nSubject:":SUBJECT:"\nServer:":ServerName:"\nAttach:":Final_Attachment:"\nBody\n%report%")

The server value must present before the attachement and body and the attachment must present before the body.
Post Reply