| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |
OmniSolutions Sponsor Message

     

Preprocess for Sendmail/iX

By Shawn M. Gordon

Inside VESOFT covers tips and techniques you can use with VESOFT’s 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 we’ll get a “3000 for 2000” cap out to you as our thanks.

This month I decided to team up Inside VEsoft with the Inside COBOL column. The results of the collaboration let you create a unified solution that lets a report e-mail its results via Sendmail/iX at completion.

I suppose that strictly speaking you could do this in plain old MPE/iX command files, but by using VEsoft’s 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


We need to get the send-to e-mail address, the CC: and the BCC: addresses, as well as specify the subject and a return e-mail address. Theoretically if you were going to launch a report and e-mail it to someone, you should probably supply your personal e-mail address as a return address. While I prompt for it here, it would be possible to configure an e mail address within Security/3000 as a UDF (User Defined Field — we haven’t talked about them yet). Then we just use a function within STREAMX to return the e-mail address into a variable based on the user’s session ID. This solution is better, but I just haven’t done it here.

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 month’s 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:
echo MIME-Version: 1.0 >>*mt
echo Content-Type: multipart/mixed; boundary=”!mail_sep” >>*mt
echo >>*mt

It’s the last line that is odd. We have to at least put some information inside the body of the e-mail or the attachments won’t 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. I’m 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. I’m not sure of what the exact problem is with the compatibility, and it’s 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.