Page 1 of 1

Unable to send Email

Posted: Fri Sep 25, 2009 2:50 pm
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

Posted: Fri Sep 25, 2009 3:23 pm
by chulett
Try switching the position of 'Server' and 'Body' in the string you build, Body should be last AFAIK.

Posted: Wed Sep 30, 2009 7:29 am
by datastageETL
Thankyou Chulett. I will try that and will let you know if that solves the issue

Posted: Wed Sep 30, 2009 7:50 am
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

Posted: Wed Sep 30, 2009 8:07 am
by chulett
Post your DSSendMail syntax again, please.

Posted: Wed Sep 30, 2009 8:31 am
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

Posted: Wed Sep 30, 2009 8:44 am
by chulett
So... I don't see any actual change. :?

Posted: Wed Sep 30, 2009 8:52 am
by datastageETL
Sorry, I got it wrong - let me send it to you again

Posted: Wed Sep 30, 2009 9:01 am
by datastageETL
Here you go

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

Posted: Wed Sep 30, 2009 9:19 am
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.

Posted: Thu Oct 01, 2009 2:15 am
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'

Posted: Thu Oct 01, 2009 5:29 am
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.

Posted: Thu Oct 01, 2009 6:03 am
by datastageETL
Thanks Craig. I will keep you updated.

Posted: Tue Oct 06, 2009 2:40 am
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.