/*************************************************************************** SENDFILE - Sends a file (created from some other program) via Email command line parameters are: sourcefile toemail fromemail priority subject where sourcefile: is the filename to send as the body of the message toemail: someone@somewhere.com fromemail: source@somewhere.com priority: Normal or Urgent subject: what should go on the subject line of message **************************************************************************/ Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' Call SysLoadFuncs /* Add the FILEREXX functions (FileRexx.Dll) */ CALL RxFuncAdd 'FileLoadFuncs', 'FILEREXX', 'FileLoadFuncs' CALL FileLoadFuncs CALL RxFuncAdd 'FileRexxFileRead','FILEREXX','FileRead' CALL RxFuncAdd 'FileRexxFileWrite','FILEREXX','FileWrite' CALL RxFuncDrop 'FileRead' CALL RxFuncDrop 'FileWrite' parse arg sourcefile msgto msgfrom priority msgdesc env = 'OS2ENVIRONMENT' ShowHelp = 0 if sourcefile = '' then showhelp = 1 if msgto = '' then showhelp = 1 if msgfrom = '' then showhelp = 1 if priority = '' then showhelp = 1 if msgdesc = '' then showhelp = 1 if showhelp = 1 then do say ' ' say 'SENDFILE.CMD - sends email with body being that of another file.' say ' ' say 'command line parameters are: sourcefile toemail fromemail priority subject' say ' ' say ' where sourcefile: is the filename to send as the body of the message' say ' toemail: someone@somewhere.com' say ' fromemail: source@somewhere.com' say ' priority: Normal or Urgent' say ' subject: what should go on the subject line of message' say ' ' exit end HomeDir = 'x:\www\mail' /* InetMail's home directory */ Mailer = 'bin\hmailer.exe' /* Name of delivery agent */ sourcehandle = FileOpen( sourcefile, 'a+rs','e',0) sourcesize = FileSeek( sourcehandle, 0, 2) dud = FileSeek( sourcehandle, 0, 0) msgtext = FileRexxFileRead( sourcehandle, sourcesize) sourcehandle = FileClose( sourcehandle) currentdirectory = directory() Junk = directory(HomeDir) /* Change to home directory */ msgfilename = time('S') headerfile = msgfilename || '.hdr' headerhandle = FileOpen( HomeDir||'\'||headerfile, 'ws-','n', 0) dud = FileSeek( headerhandle, 0, 2) dud = FilePuts( headerhandle, 'From: "'msgfrom'" <'msgfrom'>') dud = FilePuts( headerhandle, 'To: "'msgto'" <'msgto'>') dud = FilePuts( headerhandle, 'Date: 'left(DATE("W"),3)', 'DATE("N")' 'TIME("N")) dud = FilePuts( headerhandle, 'Priority: 'Priority) dud = FilePuts( headerhandle, "X-Mailer: simsware.com's SendFile.Cmd v1.01") dud = FilePuts( headerhandle, 'MIME-Version: 1.0') dud = FilePuts( headerhandle, 'Content-Type: text/plain; charset="us-ascii"') dud = FilePuts( headerhandle, 'Content-Transfer-Encoding: 7bit') dud = FilePuts( headerhandle, 'Subject: 'msgdesc' ') dud = FilePuts( headerhandle, '') dud = FilePuts( headerhandle, msgtext) dud = FilePuts( headerhandle, ' ') dud = FilePuts( headerhandle, '-----------------------------------------------------------') dud = FilePuts( headerhandle, "SendFile.Cmd (c)1997-99 by SIMS, Inc. (http://www.simsware.com)") dud = FilePuts( headerhandle, ' ') dud = FileClose( headerhandle) addressfile = msgfilename || '.adr' addresshandle = FileOpen( HomeDir||'\'||addressfile, 'ws-','n', 0) dud = FileSeek( addresshandle, 0, 2) dud = FilePuts( addresshandle, msgto) dud = FileClose( addresshandle) mailcommand = mailer || ' ' || msgfrom || ' ' || addressfile || ' ' || headerfile dud = setlocal() hostname = value('HOSTNAME',,env) dud = value('HOSTNAME','mail.simsware.com',env) mailcommand '>dud.dud' dud = value('HOSTNAME',hostname,env) dud = endlocal() exit