MAIL

Synopsis

HELP:   Mail formatting as attachment
TYPE:   OBJECT
SYNTAX: MAIL(SYSTEM='str',CCSID='str',FROM='str',TO['str'...],CC['str'...],BCC['str'...],SUBJECT='str',BODY='str',ATTACHMENT='str')

Description

The MAIL object can be used to write each file as a Base64 encoded email attachment. A sender email address should and one or more receipient email addresses must be specified (TO, CC and BCC supported). The subject header, email body text and a filename for the attachment can also be set.

The environment variables MAILADDR can be set to a default sender email address, so that it does not need to be specified every time.

The 'CSSMTP' writer with class 'A' is allocated by default for SYSOUT if this formatter is selected. The environment variable below can be used to change these defaults.

See the chapter Used Environment Variables for documentation about how to set environment variables.

Mails are generated in CCSID 1047 by default, which can changed with the corresponding parameter, if necessary.

If SYSOUT is used for sending files as emails, one email is sent for each written file. If processing multiple files and a fixed filename is specified in the writing part of the command, then all these files are concatenated into one attachment. It essentially works as if writing to disk: If one file would be written locally, one email is sent. If multiple files would be written to disk, multiple emails are sent.

With the ATTACHMENT parameter, an attachment name can be specified. By default, the given filename is used. The attachment parameter has no impact on the file handling. It only sets the attachment filename in the email header. Below a example jobstep:

//* READ A MEMBER FROM A FLAMFILE AND SEND IT AS MAIL ATTACHMENT -------
//CONV     EXEC PGM=FLCL,PARM='CONV'
//STEPLIB  DD DSN=&SYSUID..FLAM.LOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//FLAMPAR  DD *
#
 Read the member HUGO from the FLAMFILE ARCHIVE.ADC and attach it as
 GZIP compressed text file to a mail readable on a windows system.
#
READ.FLAM(FILE='<CUSER>.ARCHIVE.ADC/?HUGO')
WRITE.TEXT(METHOD=WINDOWS CCSID=1252
  FALLOC(SYSOUT(FORMAT.MAIL(
    FROM='my@addr'
    TO='you@addr'
    CC['his@addr','him@addr']
    SUBJECT='Here the FLAM member of file [copy]'
    BODY='Attached you can find the FLAM member HUGO'
))))
/*

For the subject and the attachment name Input to Output Name Mapping is supported.

Arguments