You've Got Mail!

Assuming this is the case, the next step is to create a temporary IFS file, which contains the e-mail content and is deleted by the utility program after it has been sent. Alternatively, we could've selected an option to archive the sent mail in the IFS. In the following example, the TempFile field contains the name of the file created. Note the empty parentheses following the TempCrtF procedure name indicating that no input parameters are being passed. This syntax was new for V5R1, and we think it makes it more obvious that TempCrtF is a procedure instead of a variable name. The program uses the TempFile field multiple times, as this is the name of the file containing the contents of the e-mail to be sent. This file's name becomes the first parameter passed to all our other utility procedures.

C                Eval      TempFile = TempCrtF()

The next step involved adding the sender information to the e-mail header, along with other information (e.g., the date) in the format required by the MIME standard to the temporary file. FromName and FromEmail contain the sender information. In our case, the sender is always the same; it won't change from invoice to invoice.

C     CallP    MimeSender(TempFile : FromName :  FromEmail)

Next, we added the receiver information, including the name, e-mail and whether the receiver is a "To:", "cc:" or "bcc:". For flexibility, the utility allows up to 1,000 receivers to be specified. The receiver information (which comes from the customer master record, in our case) was placed into the first elements of each of the three arrays. We then called the utility procedure MimeDistr, which added this information in the proper format (see Code Sample 1).

The next utility procedure, MimeUpdTxt, performed a lot of work at once. Remember the e-mail template file created earlier containing our e-mail's standard text? In this next call, we not only copied that standard formatted text file into our temporary file, but we also provided the values for the two substitution variables to customize the e-mail text. The utility allows for up to 500 substitution variables by accepting two arrays with 500 elements each as parameters. One contains the "names" of the variables and the second contains the variables' corresponding values.

D TxtVarArr       s             10A   DIM(500)
D TxtValArr       s            500A   DIM (500)

The name of our standard template file is also passed as a parameter, since its content must be copied into the e-mail before the text substitution can occur (see Code Sample 2).

Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.

comments powered by Disqus



2017 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

A PPP Monitor Utility

Here's a program developed to programmatically obtain the status of a PPP connection

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters