Page 1 of 1

Mail Notification

Posted: Tue Jun 28, 2005 9:56 am
by shiva459
Hi ,

I am trying to implement mail notification from a batch.I want to send an email if any job in the batch fails which will include the reason for failure.I know to implement it via graphical sequencer but not sure how to include in a batch code.
I am attaching the batch code below, please guide me how to call the DSSendMail routine in case of failure at the end of every job.
RunJobs:
* Setup XYZ, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("XYZ", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: XYZ", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "Arg1", Arg1)
ErrCode = DSSetParam(hJob1, "Arg2", Arg2)

ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: XYZ", "JobControl")
End


Thanks

Posted: Tue Jun 28, 2005 10:22 am
by ArndW
Shiva459,

on page 6-188 of the BASIC Guide you will find the exact description on how to do this; as this is very straightforward programming I am not sure where your problem is.

You need only add:

Code: Select all

   ParameterString = "From:Pseudo@Nominus.Com\nTo:Shiva459@SFBay.Org\nSubject:DSSendMail Function Call\nBody:\n"
 ReturnCode = DSSendMail(ParameterString)

Posted: Tue Jun 28, 2005 6:10 pm
by ray.wurlod
If that's not enough, look at the Routine called DSSendMailTester (in the Built-In\Utilities category) for a coded example.

Posted: Tue Jun 28, 2005 7:09 pm
by chulett
And make sure you do it before calling DSLogFatal. :wink: