SEND-EMAIL

File 212
Op-Sys z/OS, z/VSE, BS2000/OSD
Statement PROCESS
Task This view provides the support for sending electronic mails.

Common Fields for all Operating Systems

Dictionary Field Name F/L Mu DE Remarks
ERROR-CODE N3      
ERROR-TEXT A58      
NODE N5   D  
NODE-NAME A16   D  
SYSTEM-CODE B2      
SYSTEM-MESSAGE-CODE A10      
FUNCTION A8   D  
SUBJECT A128   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.

Relevant Error Codes

Code Text z/OS z/VSE BS2000/OSD
530 Access denied by Security Facility. X X X
675 HOST-CODE-PAGE not supported X X X
699 Not enough main storage available. X X  
798 Task was not started under TSOS.     X
799 Entire System Server internal error.     X
809 Subsystem not active. X X X
895 RECIPIENT must be specified. X X X
895 SUBJECT must be specified. X X X
896 Error occurred when executing E-Mail.     X
897 Mailer response: :1:. X X X
986 No or not enough space for E-mail Control Block.     X
986 No or not enough space for E-mail Data Block.     X

Field Descriptions

Field Name Type/Length Operating System
BCC-RECIPIENT (A128) M20 z/OS, z/VSE, BS2000/OSD

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 Operating System
CC-RECIPIENT (A128) M20 z/OS, z/VSE, BS2000/OSD

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 Operating System
DSNAME (A54) z/OS, z/VSE, BS2000/OSD

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

Field Name Type/Length Operating System
EXTENDED-TEXT (A250) M60 z/OS, z/VSE, BS2000/OSD

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

Field Name Type/Length Operating System
HOST-CODE-PAGE (A8) z/OS, z/VSE, BS2000/OSD

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

If omitted, Entire System Server uses the value supplied with the startup parameter HOST-CODE-PAGE. If this startup parameter is not specified, Entire System Server uses the internal default U.S. English Code Page (code page number 037/1).

Possible options for BS2000/OSD:

Option Explanation
EDF03DRV Coded character set (CCS) EBCDIC.DF.03 ISO-7-bit German
EDF03IRV Coded character set (CCS) EBCDIC.DF.03 ISO-7-bit International
EDF041 Coded character set (CCS) EBCDIC.DF.04 ISO-8-bit International
EDF04DRV Coded character set (CCS) EBCDIC.DF.04 ISO-8-bit German

Possible options for z/OS, z/VSE:

Option Explanation
HCP 1140 EBCDIC code page 1140 (Brazil, Canada, Netherlands, Portugal, U.S.)
HCP 1141 EBCDIC code page 1141 (Austria, Germany.)
HCP 1142 EBCDIC code page 1142 (Denmark, Norway)
HCP 1143 EBCDIC code page 1143 (Finland, Sweden)
HCP 1144 EBCDIC code page 1144 (Italy)
HCP 1145 EBCDIC code page 1145 (Latin America, Spain)
HCP 1146 EBCDIC code page 1146 (United Kingdom)
HCP 1147 EBCDIC code page 1147 (France)
HCP 1148 EBCDIC code page 1148 (International)
HCP 1149 EBCDIC code page 1149 (Iceland)
Field Name Type/Length Operating System
FUNCTION (A8) z/OS, z/VSE, BS2000/OSD

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 Operating System
FROM-NAME (A128) z/OS, z/VSE, BS2000/OSD

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 Operating System
IDENTIFIER (A8) z/OS, z/VSE, BS2000/OSD

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

Field Name Type/Length Operating System
IGNORE-RCPT-REJECT (A3) z/OS, z/VSE, BS2000/OSD

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 Operating System
PASSWORD (A8) z/OS, z/VSE, BS2000/OSD

Password for protected dataset.

Field Name Type/Length Operating System
RECIPIENT (A128) M20 z/OS, z/VSE, BS2000/OSD

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 Operating System
RECORD (A253) z/OS, z/VSE, BS2000/OSD

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 Operating System
REPLY-TO (A128) z/OS, z/VSE, BS2000/OSD

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 Operating System
SUBJECT (A128) z/OS, z/VSE, BS2000/OSD

Specifies the subject of the mail.

Field is required for the first SEND-EMAIL request.

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. The maximum size of one e-mail is limited to 1MB on BS2000/OSD.

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 sections Installation for z/OS (Step 15), Installation for z/VSE (Step 12), Installation for BS2000/OSD (Step 9) in the Entire System Server Installation and Customization documentation for additional information about e-mail installation requirements.

Additional Fields Supported for z/OS

Dictionary Field Name F/L Mu DE Remarks
VOLSER A6   D Only if dataset is not cataloged.
MEMBER A10   D  

Field Descriptions

Field Name Type/Length Operating System
VOLSER (A6) z/OS, z/VSE

Volume serial number (not relevant for BS2000/OSD).

Field Name Type/Length Operating System
MEMBER (A10) z/OS, z/VSE

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

Additional Fields Supported for z/VSE

Dictionary Field Name F/L Mu DE Remarks
VOLSER A6     Required in z/VSE.
MEMBER A10      
MEMBER-TYPE A8      
LIBRARY A8     Required if DSNAME not specified.
SUB-LIBRARY A8     Required if Librarian file.

Field Descriptions

Field Name Type/Length Operating System
VOLSER (A6) z/OS, z/VSE

Volume serial number (not relevant for BS2000/OSD).

Field Name Type/Length Operating System
MEMBER (A10) z/OS, z/VSE

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

Field Name Type/Length Operating System
MEMBER-TYPE (A8) z/VSE

Member type.

Field Name Type/Length Operating System
LIBRARY (A8) z/VSE

Name of library.

Field Name Type/Length Operating System
SUB-LIBRARY (A8) z/VSE

Name of sublibrary.

Additional Fields Supported for BS2000/OSD

Dictionary Field Name F/L Mu DE Remarks
ELEMENT A64      
ELEMENT-TYPE A8      
ELEMENT-VERSION A24      
ELEMENT-PASSWORD A8      

Field Descriptions

Field Name Type/Length Operating System
ELEMENT (A64) BS2000/OSD

Name of LMS element to be attached to this mail.

Field Name Type/Length Operating System
ELEMENT-TYPE (A8) BS2000/OSD

Type of LMS element to be attached to this mail.

Types C and L are currently not supported.

Field Name Type/Length Operating System
ELEMENT-PASSWORD (A8) BS2000/OSD

Password, for protected element (LMS V2 or above).

Field Name Type/Length Operating System
ELEMENT-VERSION (A24) BS2000/OSD

Version of LMS element to be attached to this mail.