$! MAIL_AT.COM $!============= $! THIS FILE MAY NOT BE MODIFIED OUTSIDE THE SYSMGT MAINTENANCE SYSTEM $! $! Command file to allow files to be emailed as mime attachments. $! $! Each file specified will be copied to OPS$MAIL to obtain a spool effect. $! The process then submits itself into batch to complete the MIME encoding $! and emailing process. The spool is cleaned after 3 days. $! $! Extentions are predefined as binary or ascii. Ascii for undefined extentions. $! Some extentions are transformed to make it usable on PC (e.g. LOG and $! COM become TXT). $! $! Error reporting is done in BNT and sys$output $! $! P1 = Attachment files, seperated by commas, no blanks allowed, wildcards allowed $! P2 = Email address/s, seperated by commas $! P3 = Subject Line $! P4 = text file containing mail content, default text available $! P5 = "PDF" all files will be converted to a close match width pdf file $! P6 = ACTION (SUBMIT/PROCESS), internal usage $!------------------------------------------------------------------------------ $! Examples : $! @mail_at fin_rep.txt sybase@ing.be,fallon@ing.be "Financial Reports" $! @mail_at b*.log;* sybase@ing.be "All Versions of Log files" $! @mail_at u1012*.txt; u1012@total.be "Customer u1012 reports" $! $! $create mail.txt $! Greetings from ING" $! $ $! @mail_at u1012*.txt; u1012@total.be "Customer u1012 reports" mail.txt $! $ d:=write sys$output $ pid=f$getj(0,"pid") $ user=f$edit(f$getjpi(0,"username"),"trim") $ this=f$env("procedure") $ mailh="ops$mail:mailhead_''pid'.tmp" $ on warning then goto error $ file = "''p1'" $ address = "''p2'" $ subject = "''p3'" $ textf = "''p4'" $ pdf = f$ed(p5,"lowercase") $ action = f$ed(p6,"lowercase") $ if action .eqs. "" then action = "submit" $ $ if f$trnlnm("mail$max_filesize") .nes. "" $ then $ max_size = f$int(f$trnlnm("mail$max_filesize")) $ else $ max_size = 5000 $ endif $ $ if textf .nes. "" .and. f$sea("''textf'") .eqs. "" $ then $ call wms W "Cannot find file ''textf'" $ goto end $ endif $ $ if file .eqs. "" then goto bad_param $ if address .eqs. "" then goto bad_param $ if subject .eqs. "" then goto bad_param $ $ if action .eqs. "submit" then goto submit $ if action .eqs. "process" then goto process $ $ goto bad_param $ $submit: $ size=0 $ gosub split_filename $ $ submit/noprint/keep 'this'/param=("''filestring'","''address'","''subject'","''textf'","''pdf'","process") $ goto end $ $process: $ sh symb p% !for debug $ set verif $ if f$mode() .eqs. "BATCH" then set proc /name="MAIL_''pid'" $ $ gosub split_filename $ $ count = 0 $ $ open /write scriptfile ops$mail:mailscript_'pid'.tmp $ write scriptfile "$ run sys$system:mime.exe" $ write scriptfile "open ''mailh' /draft" $ $process_loop: $ if f$type(fileelem_'count') .eqs. "" then goto end_process_loop $ $ filetemp = fileelem_'count' $ $ filetype = f$parse("''filetemp'",,,"type") - "." $ filename = f$parse("''filetemp'",,,"name") $ $ filemode = "ASCII" $ if filetype .eqs. "CSV" then filemode = "ASCII" $ if filetype .eqs. "TXT" then filemode = "ASCII" $ if filetype .eqs. "ZIP" then filemode = "BINARY" $ if filetype .eqs. "PDF" then filemode = "BINARY" $ $ if pdf .eqs. "pdf" $ then $ d "Converting to pdf : ''filetemp'" $ set noverif $ open/read x 'filetemp' $ lrl_max=1 $lrl_loop: $ read/end=lrl_end x x_rec $ lrl=f$len(x_rec) $ if lrl .gt. lrl_max then lrl_max=lrl $ goto lrl_loop $lrl_end: $ close x $ set verif $ mc sysapp:[public]txt2pdf <'filetemp' >ops$mail:'filename'.pdf ='lrl_max' ! not dcl_check compliant $ filetemp=f$sea("ops$mail:''filename'.pdf") $ filemode = "ASCII" ! Note that only such generated files are ascii $ endif $ $ if filemode .eqs. "ASCII" $ then $ write scriptfile "ADD ''filetemp'" $ else $ write scriptfile "ADD ''filetemp' /BINARY" $ endif $ $ count = count + 1 $ goto process_loop $ $end_process_loop: $ write scriptfile "SAVE" $ write scriptfile "EXIT" $ close scriptfile $ $ create 'mailh' Mime-version: 1.0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: Content-Disposition: inline

THIS EMAIL WAS SENT BY AN AUTOMATED SYSTEM
- PLEASE DO NOT REPLY TO THIS MESSAGE -


$ $ if textf .nes. "" $ then $ open/append x 'mailh' $ write x "
"
$    close x
$    convert/append 'textf' 'mailh'
$    open/append x 'mailh'
$    write x "
" $ close x $ else $ open/append x 'mailh' $ write x "

Please find your report or data files attached.

" $ close x $ endif $ @ops$mail:mailscript_'pid'.tmp $ $ mail 'mailh' "''address'" /subject="''subject'" $ goto end $ $split_filename: $ count = 0 $ filestring = "" $ $split_filename_loop: $ wild_fileelem = f$elem(count,",",file) $ $ if wild_fileelem .eqs. "," $ then $ filestring = filestring - "," $ goto end_split_filename $ endif $ $ if f$locate("%",wild_fileelem) .lt. f$len(wild_fileelem) .or. f$locate("*",wild_fileelem) .lt. f$len(wild_fileelem) $ then $next_wildfile: $ fileelem=f$sea(wild_fileelem,1) $ if fileelem .eqs. "" then goto end_wildfile $ gosub proc_file $ goto next_wildfile $end_wildfile: $ else $ fileelem=wild_fileelem $ gosub proc_file $ endif $ goto split_filename_loop $end_split_filename: $ if action .eqs. "submit" $ then $ if (size/1024) .gt. max_size $ then $ call wms W "File set is larger (''size' bytes) than allowed limit of ''max_size' K. May go wrong !!!" $ endif $ endif $ return $ $ $proc_file: $ if f$sea("''fileelem'") .eqs. "" $ then $ call wms E "Cannot find file ''fileelem'" $ goto end $ endif $ fileelem_vers=f$sea("''fileelem'") !to add version $ $ filedrv = f$parse("''fileelem'",,,"device") $ filedir = f$parse("''fileelem'",,,"directory") $ filename = f$parse("''fileelem'",,,"name") $ filetype = f$parse("''fileelem'",,,"type") - "." $ $ if action .eqs. "submit" $ then $ if filetype .eqs. "SPF" then filetype = "TXT" $ if filetype .eqs. "OUT" then filetype = "TXT" $ if filetype .eqs. "LOG" then filetype = "TXT" $ if filetype .eqs. "COM" then filetype = "TXT" $ if filetype .eqs. "LIS" then filetype = "TXT" $ if filetype .eqs. "SPD" then filetype = "CSV" $ filenamefull="''filename'.''filetype'" $ size=size + f$file("''fileelem'","eof") * 512 $ backup/ignore=int/log 'fileelem_vers' ops$mail:'filenamefull'; $ set file ops$mail:'filenamefull';/prot=(w:rwed) !allow overwrite $ fvers=f$parse(f$sea("ops$mail:''filenamefull';"),,,"version") $ filestring = filestring + ",ops$mail:''filenamefull'''fvers'" $ else $ fileelem_'count' = fileelem $ endif $ $ count = count + 1 $ return $ $bad_param: $ call wms E "Illegal parameters used. See header of ''this'" $ goto end $ $error: $ call wms E "Unhandled error in ''this'" $ goto end $ $end: $ exit %x00001 $ $wms: SUBROUTINE $ @wms$com:wms_send_bwd "%WMS_''p1'_MAIL>SYSMGR>''P2' (user ''user')" $ d "-''p1'-''p2'" $ if action .eqs. "process" then sh symb * $ $ exit $ ENDSUBROUTINE