You've Got Mail!

Imagine the impact to your company's bottom line of e-mailing invoices to customers instead of "snail-mailing" them. Not only would postage and handling costs be reduced, cash flow would improve because customers should receive the invoices faster. Now, what if it were a pretty simple process to do from your RPG-invoice printing program and you could convert your regular spool-file invoice to a PDF, attach it to a personalized e-mail note for each customer and send it-all without spending weeks trying to figure out how to make all of the details work? If this sounds too good to be true, read on. We're about to show you a simple example program that does just that.

Some of you may remember that we've written about the CGIDEV2 tool from IBM, which is supported by the Easy400 Web site and its webmaster, Giovanni Perotti. Lately, Perotti has been busy creating even more tools to help simplify the integration of modern technology into RPG and COBOL applications.

One such tool is the MIME & Mail utility. MIME, which stands for Multipurpose Internet Mail Extensions, is a set of standards for sending e-mail messages around the Internet. You can certainly send e-mails from RPG and COBOL programs without using this tool. And some programmers have successfully used the Send Distribution (SNDDST) CL command for e-mail, but it has many limitations. Some other brave souls have used the "raw" system APIs, just as one could write RPG and COBOL Web applications using the "raw" APIs. The MIME & Mail utility simplifies the process and documents the interfaces in terms that make more sense to RPG and COBOL programmers, as CGIDEV2 did for Web programming.

The Three Steps

E-mailing an invoice involves three basic steps. First, you must create the standard text template for the e-mail. This step can be done once using a green-screen interactive interface and saving the results in the IFS. Our invoice-creation RPG program handles the remaining steps. The second step personalizes the e-mail content, attaches the invoice file and provides the necessary distribution details in the appropriate MIME-standard format. The third step sends the e-mail using OS/400* SMTP support.

Creating the standard-text template is a fairly simple one-time process. Create the text you want (including substitution variables) in an IFS file, and then add the necessary e-mail header information, including a subject line, priority and content type using the menu- driven interface that's part of the MIME & Mail utility.

Since we personalize the e-mail for each customer, we included substitution variables for the customer's name and the invoice date. It may sound like this would be a simple task without the utility, but the standard format of the information required is cumbersome and difficult to figure out on your own. Take the easy way out and use the utility. (Note: This utility has both a green-screen and Windows* graphical interface.) For our example, the contents of our generated template are shown in Figure 1. Note the two substitution variables (&NAME and &DATE).

Next, we wrote a program that's called by the invoice-printing application, passing as parameters the customer number and the name of the file containing the customer's invoice information. The program chains to the customer's record to ensure that an e-mail address is known.

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



2019 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