Sending HTML Email From Your Mainframe

2 Pages

To send HTML-formatted email, you must use the Multi-purpose Internet Mail Extensions (MIME) standard. This extends email support to include non-text attachments and text in character sets other than ASCII. MIME also provides a standard way to send HTML-formatted email.

The batch job in Figure 3 generated the email shown in Figure 1. Three PDS members are concatenated under the SYSUT1 DD statement; each contains parts of the entire HTML-formatted email message. This setup makes it easier to modify the dynamic portion of the email via our automated performance-monitoring system. When our performance-monitoring system detects that the CPU utilization has been at 90 percent or greater for a 30-minute interval, it will replace the EMAILP2 member with the appropriate text, and then submit the batch job shown in Figure 3.

SMTP Statements

The first section of the email message is contained in the EMAILP1 member. The EMAILP1 member is shown in Figure 4. The statement numbers shown in Figure 4 are for illustration purposes only. Statements 1 through 7 are used to tell SMTP about the email message. These seven statements tell SMTP who the message is from, who the message is to, and the subject of the email. In statement 1, APCTSAPT is the Network Job Entry (NJE) name of the MVS node we’re running this batch job on. But I can put anything I want in place of APCTSAPT and the job still works fine.

Statements 9 and 10 tell SMTP we’ll be using MIME to generate an email that may contain both text and HTML-formatted data.

HTML Statements

The HTML statements start at line 10 in Figure 4. Statement 25 defines a table that has a width of 100 percent. This table is used to set the background color. You also could set the background color using the <BODY> statement, but some email programs delete the <BODY> statement, so setting the color using a table is safer.

In statement 29, another table is created within the first table. This second table has a width of 600 pixels. Many email users view their email using the email program’s preview pane. You should make your HTML emails thin enough to look good within the preview pane. Experiment with different widths, viewing your email message both with and without the preview pane.

Statements 30 through 32 show you how to include an image in your HTML-formatted email message. Statement 30 starts a new table row. Statement 31 identifies the image to be included, and statement 32 ends the table row.

The EMAILP2 member is updated to reflect the date, time, and actual CPU busy percentage when our automated performance monitoring system detects a high-CPU utilization condition. This portion of the message was split out from the rest of the email message to make it easier for the performance monitoring system to format the message (see Figure 5).

EMAILP3 member, shown in Figure 6, contains the remainder of the HTML-coded email message.


The sample HTML email message illustrated in this article is a bare bones-type of email. You should take this sample and experiment. Add your own graphics, throw in a few links, and change the colors. It’s possible to create your email message using an HTML editor, such as Dreamweaver and FrontPage, but you’ll probably have to manually massage the generated HTML code to work properly with your email system.

There’s also a flaw in the z/OS SMTP service. Notice that in Figure 4 the name of the email sender is specified. You can actually put any name you want in this field and it will pass right through the SMTP server as coded. Using this flaw to send emails posing as others isn’t a great idea. Remember, System Management Facility (SMF) captures everything, so exploiting this flaw can be traced back to you.

You also must ensure the member (or data set) containing your HTML and SMTP statements isn’t numbered. If you have numbers in columns 73 through 80, it can wreak havoc. Use the ISPF UNNUM command to eliminate these sequence numbers. Z


  • IP Users Guide and Commands: http://publibz.
  • Getting Started With SMTP:
  • IP Configuration Guide:
  • IP Configuration Reference: http://publibz.boulder.
  • General HTML Email Guide:  

2 Pages