SEND-EMAIL

File 212
Statement PROCESS
Task This view provides the support for sending electronic mails.

Fields

Dictionary Field Name F/L Mu DE Remarks
ATTACHMENT-SUFFIX A4      
ERROR-CODE N3      
ERROR-TEXT A58      
NODE N5   D  
NODE-NAME A16   D  
SYSTEM-CODE B2      
SYSTEM-MESSAGE-CODE A10      
FUNCTION A8   D  
SUBJECT A253   D  
RECORD A253   D  
RECIPIENT A128 M20 D  
CC-RECIPIENT A128 M20 D  
BCC-RECIPIENT A128 M20 D  
IGNORE-RCPT-REJECT A3   D  
FROM-NAME A128   D  
REPLY-TO A128   D  
HOST-CODE-PAGE A8   D  
DSNAME A54   D  
PASSWORD A8   D  
EXTENDED-TEXT A250 M60    
IDENTIFIER A8   D Required for nested SEND-EMAIL requests.
VOLSER A6   D Only if dataset is not cataloged.
MEMBER A10   D  

Relevant Error Codes

Code Text
530 Access denied by Security Facility.
675 HOST-CODE-PAGE not supported
699 Not enough main storage available.
809 Subsystem not active.
895 RECIPIENT must be specified.
895 SUBJECT must be specified.
897 Mailer response: :1:.

Field Descriptions

Field Name Type/Length
ATTACHMENT-SUFFIX (A4)

The field has a maximum length of 4 characters, so for example if the user sets ATTACHMENT-SUFFIX := 'html' or ATTACHMENT-SUFFIX := 'txt', .html resp. .txt will be appended to the attachment name, making it a valid file extension for e.g. Windows. Also, whole web pages, stored in a DS/Member, can be sent with ATTACHMENT-SUFFIX := 'html' for easier access in a web browser directly from the mail client.

Field Name Type/Length
BCC-RECIPIENT (A128) M20
Field Name Type/Length
BCC-RECIPIENT (A128) M20

Array of max. 20 recipients receiving a "blind carbon copy" of this mail.

If blank, no "blind carbon copy" will be sent. This field is optional.

Field Name Type/Length
CC-RECIPIENT (A128) M20

Array of max. 20 recipients receiving a "carbon copy" of this mail.

If blank, no "carbon copy" will be sent. This field is optional.

Field Name Type/Length
DSNAME (A54)

Fully qualified data set name that is attached to this mail as a text file.

Field Name Type/Length
EXTENDED-TEXT (A250) M60

Array of max. 60 SMTP reply codes and texts from mail server in case of rejected [CC-/BCC-]RECIPIENTs.

Field Name Type/Length
HOST-CODE-PAGE (A8)

This field identifies the host code page of all SEND-EMAIL input fields provided by the user.

If this startup parameter is not specified, Entire System Server uses the internal default U.S. English Code Page (code page number 037/1).

Field Name Type/Length
FUNCTION (A8)

Function to be performed. Possible options:

Option Explanation
blank Default. Write a mail record.
CLOSE All mail records have been written. Specify this function for the last SEND-EMAIL request.
Field Name Type/Length
FROM-NAME (A128)

last_name and first_name as additional sender information. Field must not contain any quotation marks. The required quotation marks in the mail header will be added automatically.

Field Name Type/Length
IDENTIFIER (A8)

Required for nested SEND-EMAIL requests. All requests for the same mail must have the same identifier.

Field Name Type/Length
IGNORE-RCPT-REJECT (A3)

Possible values:

Option Explanation
YES The e-mail is sent even if a specified RECIPIENT is rejected by the SMTP server.
NO The e-mail is not sent if a specified RECIPIENT is rejected by the SMTP server (default).
Field Name Type/Length
PASSWORD (A8)

Password for protected dataset.

Field Name Type/Length
RECIPIENT (A128) M20

Array of max. 20 recipients receiving this mail.

At least one recipient is required for the first SEND-EMAIL request to send this mail.

Field Name Type/Length
RECORD (A253)

Mail record to be written as line in the message body.

Note
If the first RECORD starts with the string "<html" or "<!DOCTYPE HTML", the e-mail is sent with an indication that it contains text in HTML format, otherwise it will be sent as plain text.

Field Name Type/Length
REPLY-TO (A128)

The specified mail address is sent to all mail recipients to provide a specifiy reply address. This field is optional. If omitted, user ID and host name are taken to compose the reply address.

Field Name Type/Length
SUBJECT (A253)

Specifies the subject of the mail.

Field is required for the first SEND-EMAIL request.

Field Name Type/Length
VOLSER (A6)

Volume serial number .

Field Name Type/Length
MEMBER (A10)

If dataset is a PDS, member name to be attached to this mail.

Example

The following example illustrates the usage of the SEND-EMAIL view. The PROCESS statement is encapsulated in subroutine SUB-SEND-EMAIL.

DEFINE DATA LOCAL
1 SEND-EMAIL VIEW OF SEND-EMAIL
  2 ERROR-CODE
  2 ERROR-TEXT
  2 NODE
  2 NODE-NAME
  2 SYSTEM-CODE
  2 SYSTEM-MESSAGE-CODE
  2 FUNCTION
  2 SUBJECT
  2 RECORD
  2 RECIPIENT    (1:20)
  2 CC-RECIPIENT (1:20)
  2 IDENTIFIER
1 #FUNCTION      (A008) INIT <" ">
1 #SUBJECT       (A128) INIT <"Test mail">
1 #RECORD        (A080)
1 REDEFINE #RECORD
  2 #RECORD1     (A040)
  2 #RECORD2     (A040)
1 #RECIPIENT     (A128) INIT <"email_address"> <-- change this
1 #NODE          (N005) INIT <node>            <-- change this
END-DEFINE
*
ASSIGN #RECORD1   = "Dear User,"
ASSIGN #RECORD2   = " "
PERFORM SUB-SEND-EMAIL
*
ASSIGN #RECORD1   = "this is a mail sent by a Natural test pr"
ASSIGN #RECORD2   = "ogram."
PERFORM SUB-SEND-EMAIL
*
ASSIGN #RECORD1   = " "
ASSIGN #RECORD2   = " "
PERFORM SUB-SEND-EMAIL
*
ASSIGN #RECORD1  = "Best Regards,"
ASSIGN #RECORD2  = " "
PERFORM SUB-SEND-EMAIL
*
ASSIGN #RECORD1  = "NPR Development"
ASSIGN #RECORD2  = " "
PERFORM SUB-SEND-EMAIL
*
ASSIGN #FUNCTION = 'CLOSE'
ASSIGN #RECORD1  = " "
ASSIGN #RECORD2  = " "
PERFORM SUB-SEND-EMAIL
*
DEFINE SUBROUTINE SUB-SEND-EMAIL
  PROCESS SEND-EMAIL USING NODE      = #NODE
                       ,   FUNCTION  = #FUNCTION
                       ,   SUBJECT   = #SUBJECT
                       ,   RECORD    = #RECORD
                       ,   RECIPIENT = #RECIPIENT
*
  IF ERROR-CODE NE 0
    WRITE    9X   '=' ERROR-CODE
          /  9X   '=' ERROR-TEXT
          /  8X   '=' SYSTEM-CODE
                / '=' SYSTEM-MESSAGE-CODE
    NEWPAGE
    STOP
  END-IF
END-SUBROUTINE
END 

Supplementary Information about SEND-EMAIL

The SEND-EMAIL view implements a text-based mail client. The message body is created based on text lines specified in field RECORD. To support a varying number of text lines, SEND-EMAIL was designed as an update view. The mail message body is closed by specifying FUNCTION='CLOSE'.

RECORD is defined as a 253-byte character field. The data specified in the RECORD field will be terminated by carriage return and line feed in the message body.

A zero ERROR-CODE is returned from SEND-EMAIL if the e-mail has been accepted by the SMTP server. This does not necessarily mean that the e-mail could be delivered to the specified RECIPIENT(s) and CC-RECIPIENT(s).

A character set translation is needed before sending all mail data to the configured SMTP target host. Therefore, the input EBCDIC data will be converted to ASCII code page ISO 8859-1. No special characters are supported as RECORD data.

Currently, the SEND-EMAIL view does not support data encryption.

If startup parameter and user field HOST-CODE-PAGE are omitted, the SEND-EMAIL view uses the U.S. English Code Page (code page number 037/1) as character set for input data. The at-sign @ as part of various mail addresses can be supplied as (a) (left bracket, lower case a, right bracket) to simplify the input procedure. If you encounter problems with the @ character, use (a) instead. Error ESY5879 Mailer response: Send RCPT TO failed with RC 550 indicates problems with the RECIPIENT field.

For more information about e-mail administration, see the subsection Run E-Mail Client in Common Entire System Server Features in the Entire System Server Administration documentation. See the subsection E-Mail Client Requirements in the section Installation for z/OS (Step 15) in the Entire System Server Installation and Customization documentation for additional information about e-mail installation requirements.

On this page