|
Preprocess for Sendmail/iX Inside VESOFT covers
tips and techniques you can use with VESOFTs products,
especially MPEX. As always, I am totally open to getting input from
you users of MPEX, Security/3000 or VEAudit/3000 it helps me
learn, too. Send me your tricks, and well get a 3000 for
2000 cap out to you as our thanks. I suppose that strictly speaking you could do this in plain old MPE/iX command files, but by using VEsofts STREAMX in Figure 1, we get some very cool submission time parameters for prompting. A number of steps are required to set up the parameters for Sendmail. This STREAMX command file will generate a temp file that contains all of the address information needed to email a report. Another process will append the HTML and spool data to the file to send it through SENDMAIL. Figure 1 assign rm="![randomname]" + ".DATA" nomsg purge !rm build !rm;rec=-210,,f,ascii;disc=1000000 !setvar rm,'{rm}' file mt={RM},old # Generate a unique MIME boundary string, could be anything, but this works assign mail_sep rht(rpt('-',36)+"!HPSUSAN!HPPIN!HPCPUMSECS",36) # assign to = "z" while to <> " " PROMPT STRING to = "Enter a send to email address, [enter] to end";default=" " if to <> " " echo To: !to >>*mt endif endwhile # assign cc = "z" while cc <> " " PROMPT STRING cc = "Enter a CC email address, [enter] to end";default=" " if cc <> " " echo CC: !cc >>*mt endif endwhile # assign bcc= "z" while bcc <> " " PROMPT STRING bcc = "Enter a BCC email address, [enter] to end";default=" " if bcc <> " " echo BCC: !bcc >>*mt endif endwhile # PROMPT STRING from = "Enter a return email address";default="no_one@notes.fh.com" echo FROM: !from >>*mt # PROMPT STRING subject = "Enter a subject for email";& CHECK = (LEN(RTRIM(subject))) > 1;& CHECKERROR = "You must have a subject" echo SUBJECT: !subject >>*mt # echo MIME-Version: 1.0 >>*mt echo Content-Type: multipart/mixed; boundary="!mail_sep" >>*mt echo >>*mt echo This is a multi-part message in MIME format. >>*mt !setvar mail_sep,--{mail_sep} !setvar send_mail,true !file mt={RM},old
A big issue with sending a
report is in preserving the layout characteristics of the report.
Just putting it into the body of an e-mail will probably result in
proportional fonts and misalignment of the data. I struggled with
this for some time, and finally decided to convert the report to HTML
(this is covered in more detail in this months Inside COBOL
column) and then attach it to the e-mail. That is why you will see
all these references to mail_sep and MIME and such. The command file is fairly
well documented, so you should just need to read through it to
determine what is going on. There is a mix of :: for STREAMX and !
for MPE, because I needed things to execute at particular times.
Since this particular function is in an external file, we do ::USE
mail.cmd inside of our job stream to resolve it. All the stuff with
the ! Character in front of it will end up in the final submitted job
stream. A funny thing at the end
you will see is: Its the last line that is odd. We have to at least put some information inside the body of the e-mail or the attachments wont work correctly. I messed with this a bunch to find the right mix of parameters. Sendmail has a dizzying number of features available to it. I have a thousand-page book on Sendmail, which probably hurt a bit more than it helped. Im extremely grateful to Mark Bixby for porting Sendmail, but it can be a challenge to set up and use at times. A word of warning: Mark
has a great sample command file for sending spool files through
Sendmail. Most people use these to get started, and I could never
understand why no one was complaining about them. Well, it turns out
that the command files work just fine inside of MPE/iX, but will fail
whenever you try to use them from within MPEX. Since I am always
inside MPEX, I was getting very frustrated, but it did force me to
read through and understand exactly what Mark was doing. Im not
sure of what the exact problem is with the compatibility, and
its not an issue for me at the moment, but just keep it in mind
if you choose to go this route as a learning tool. You can move on to the
Inside COBOL column to complete the project. Shawn Gordon,
whose S.M. Gordon & Associates firm supplies HP 3000 utilities,
has worked with 3000s since 1983. Copyright The 3000 NewsWire. All rights reserved. |