Sending mail from a CL program

Log in to save

You need to notify someone when a batch job finishes. The shortest route is SNDSMTPEMM, an ordinary CL command that requires nothing to be installed.

SNDSMTPEMM RCP((operations@company.com))                      +
           SUBJECT('Month end close completed')               +
           NOTE('Processing finished at ' *CAT %CHAR(%TIME()))

To attach a file from the IFS, add ATTACH:

SNDSMTPEMM RCP((operations@company.com))     +
           SUBJECT('Close report')            +
           NOTE('Summary attached.')          +
           ATTACH(('/home/batch/close.csv'))

Warning

the command requires SMTP to be started (STRTCPSVR SERVER(*SMTP)) and the running profile to have an entry in the system directory. If either is missing the command fails without saying which: check with CHKSMTP first.

Note

the NOTE text is limited in length. For longer messages, write the body to a file on the IFS and attach it rather than composing it in the program.


Releases. SNDSMTPEMM is present on every release still in support. The real constraint is not the version but the configuration: SMTP started and the profile present in the system directory. Check with CHKSMTP and WRKDIRE.

← Back to blog

Comments

No comments yet. Be the first to comment!

You need an account to comment. Log in · Sign up