Email content from a text file
Posted: Tue Sep 12, 2006 6:20 am
I'm trying to create the content for an email from a text file. The email contains an output from an SQL statement. The statement returns multiple rows. In the actual email only the last line from the file is displayed.
The code is as follows:
Originally I had Error_output equating to LineData, but that seemed unecessary.
The code is as follows:
Code: Select all
Reportdate = OConv(@DATE-1, "D-DMY[,A3,]")
LineData = ""
Error_output = ""
*
*
* Setup Load_error_check, run it, wait for it to finish, and test for success
hJob2 = DSAttachJob("Load_error_check", DSJ.ERRFATAL)
If NOT(hJob2) Then
Call DSLogFatal("Job Attach Failed: Load_error_check", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob2, "Reportdate", Reportdate)
ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob2)
Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
Begin Case
Case Status = DSJS.RUNFAILED
Call DSLogWarn("Job Failed: Load_error_check", "JobControl")
Case Status = DSJS.RUNWARN
Call DSLogWarn("Job ran with warning: Load_error_check","JobControl")
Case Status = DSJS.RUNOK
Call DSLogInfo("Load_error_check completed successfully.", "JobControl")
Case 1
Call DSLogInfo("Load_error_check ran with status ":Status, "JobControl")
End Case
InputDataFile = "G:\DataStage\Outbox\load_error.txt"
OpenSeq InputDataFile To InputData Then
READ:
ReadSeq LineData from InputData Then
End
Closeseq InputData
*
EMail = ''
EMail<1> = "To:whatever_email@abc123.com\n"
*
* Construct the e-mail body
*
DateDay = Oconv(Date(),"DWA")
TimeDay = OCONV(Time(),"MTH")
message = ""
sender = ""
sender = "From:Data_Staqe_Dwetl2@appliedcard.com\n"
message = "Subject:Load Errors ":DateDay:" ":TimeDay:"\n"
message = message:"Server:172.17.90.80\n"
message = message:"Body:\n"
message = message:"Failure Status of Inbound Data for v_inbound3\n"
message = message:"---------------------------------------------\n"
message = message:" ":"\n"
message = message:" ":"\n"
message = message:" ":"\n"
message = message:LineData:"\n"
message = message:" ":"\n"
message = message:" ":"\n"
message = message:" ":"\n"
message = message:"Have a nice day!":"\n"
*
* Send the e-mail's
*
For L = 1 to COUNT(EMail,@AM)+1
EMailMessage = ""
EMailMessage = sender
EMailMessage = EMailMessage:EMail<L>
EMailMessage = EMailMessage:message
code = ''
code = DSSendMail(EMailMessage)
If code = 0 Then
Call DSLogInfo("E-mail sent successfully.",'Job Control')
End Else
Call DSLogInfo("E-mail NOT sent.",'Job Control')
End
Next L
RETURN