H NOMAIN EXPROPTS(*RESDECPOS) H AlwNull(*UsrCtl) //******************************************************************** // Program Name -- SNDEMAIL // Written By -- J.J.F. Date Written -- 12/01/2017 // Modified By -- X.X.X. Last Revision -- XX/XX/XXXX //******************************************************************** // List all modifications to this program below in the // format of initials, date & description of your change. // Initials Date Description // J.J.F. 08/11/16 Procedures //******************************************************************** // *-* Module Description *-* // // send emails with/without attachemnts // //******************************************************************** //==============================================================* // DATA SPECIFICATIONS * //--------------------------------------------------------------* // -------------------- Data Structures -------------------- // ------------------ Standalone Variables ----------------- d attach s n inz('0') d count s 10 0 inz d defaultUser s 10 inz d IHaveAnError s n inz('0') d MaxDataStructureCount... d s 10i 0 inz d Q s 1 inz('''') // ---------------------- Data Structures ------------------ *----------------------------------------------------------------- * program status dataarea *----------------------------------------------------------------- d PgmSts SDS d P1User 254 263 d @PGM *PROC d @JOB 244 253 //==============================================================* // PROTOTYPES * //--------------------------------------------------------------* /copy qprcsrc,SDEMAIL_CP /copy qprcsrc,COMMAND_CP //==============================================================* // PROCEDURE INTERFACE * //--------------------------------------------------------------* pSendEmail b export d SendEmail pi n d Inparms 5050 /Free //=============================================================* // M A I N L I N E * //-------------------------------------------------------------* *inlr = *on; mydata.allmydata = InParms; reset Attach; // How many emails do I have? // SNDSMTPEMM // RCP((JAMIEf@rockfordBallScrew.COM) // (someoneElse@RockfordBallScrew.COM *CC)) // SUBJECT('this is testing SNDSMTPEMM') // NOTE('This is a note') // ATTACH(('/home/jamie/myfile.csv' *EXCEL) // (DELETEDCUSTOMER.ZIP *ZIP) // ('20160525_143559.jpg' *JPEG)) // CONTENT(*HTML) if mydata.emailaddresses.address(1) = *blanks; IHaveAnError = *on; endif; OneThousandLong = 'SNDSMTPEMM RCP('; for count = 1 to 20; if mydata.emailaddresses.address(count) <> *blanks; OneThousandLong = %trim(OneThousandLong) + '(' + %trim(mydata.emailaddresses.address(count)) + ')'; endif; endfor; OneThousandLong = %trim(OneThousandLong) + ') SUBJECT(' + Q + %trim(mydata.subject) + Q + ') ' + ' NOTE(' + Q + %trim(mydata.body) + Q + ') ' ; for count = 1 to 10; if mydata.attachments.fullpath(count) <> *blanks; if attach = *off; OneThousandLong = %trim(OneThousandLong) + ' ATTACH('; attach = *on; endif; OneThousandLong = %trim(OneThousandLong) + '(' + Q + %trim(mydata.attachments.fullpath(count)) + Q+ ' ' + %trim(mydata.attachments.type(count)) + ')'; endif; endfor; // if mydata.attachments.fullpath(1) <> *blanks; if attach = *on; OneThousandLong = %trim(OneThousandLong) + ')'; endif; OneThousandLong = %trim(OneThousandLong) + ' CONTENT(*HTML)'; monitor; runcommand(OneThousandLong); on-error; IHaveAnError = *on; endmon; Return IhaveAnError; /End-Free PSendEmail e