Home The Company Publications Products Links Tips Jobs

Tips, Tricks, and Techniques

Last update: 21 February 2006

How to Send E-mail From a Natural Program?

Question:

We have a need to deliver email from our Natural application. We can currently send it using Natrje with a Rexx program, but have not been able to figure out how to create an attachment with that email message. I know that others have created email systems. Do you have a way of attaching to the email message?

Answer:

Here are some things you can try. MVS JCL follows:

//STEP01  EXEC PGM=IEBGENER
//SYSUT2   DD  SYSOUT=M,DEST=(UCCCMVS,S47SMT)
//SYSIN    DD  DUMMY
//SYSPRINT DD  SYSOUT=A
//SYSUT1   DD  DSN=NADT.LIB.EMAIL(NADTSKS),DISP=SHR
//         DD  DSN=NADT.LIB.EMAIL(@MIME1),DISP=SHR
//         DD  DSN=NADTSKS.JCL.LIB(TEXT),DISP=SHR
//         DD  DSN=NADT.LIB.EMAIL(@MIME2),DISP=SHR
//         DD  DSN=NADT.LIB.EMAIL(@QUIT),DISP=SHR
//

Probably, the SYSUT2 statement has to be modified.

Contents of NADT.LIB.EMAIL(NADTSKS)

000001,HELO UCCCMVS.BITNET
000002,MAIL FROM:
000003,RCPT TO:
000004,DATA
000005,From:    UniverSIS@uc.edu
000006,To:      Kent.Sinkey@uc.edu
000007,Subject: Mainframe Email

Contents of NADT.LIB.EMAIL(@MIME1)

000001 Mime-Version: 1.0
000002 Content-Type: multipart/mixed; boundary="===_boundary_==="
000003
000004 --===_boundary_===
000005 Content-Type: text/plain; charset="us-ascii"
000006
000007 Double Click the attached icon to open.
000008 --===_boundary_===
000009 Content-Type: text/plain; charset="us-ascii"
000010 Content-Disposition: attachment; filename="widget.txt"
000011

Note: The blank lines are required.

NADTSKS.JCL.LIB(TEXT)

This can be any text file or data, etc. that you want to be in widget.txt attachment.

Contents of NADT.LIB.EMAIL(@MIME2)

000001,--===_boundary_===

Contents of NADT.LIB.EMAIL(@QUIT)

000001,.
000002,QUIT

Now, all of this can be done within a natural program or you can read things in with work files and write them out with a work file.

See "Generating email from mainframe"

More detailed examples from Feb 2006

Top Page


Back to NATURAL Tips, Tricks, Techniques -- Overview