Using the SEND_EMAIL Block for Electronic Mail Notification
Original instructions
SEND_EMAIL Representation
To send an email message from the application (configured through the SMTP Control Expert screen), use a SEND_EMAIL function block. The addressing to use to send a message to the email service is: rack, slot, channel=3. The address entry of the SEND_EMAIL function block requires the NetLink where the email should go out from. The sendBuffer takes the user payload (ASCII text string). A dedicated email errCode output is defined.
Parameter Description
The following table describes the input parameters:
Parameters
Data Type
Description
ADR
ARRAY [0...7] OF INT
Use the ADDM function block to build this field. Note that this email service is limited to the embedded Ethernet port on the CPU. If the application sends an email to an NOE module, you will get a destination address incorrect error code.
HEAD_KEY
INT
Corresponds to the email’s addresses handled with Control Expert software (only 1, 2, and 3 are accepted).
SUBJ_STR
STRING
Represents the dynamic part of the email subject that is appended to the static subject string.
BODY_STR
STRING
Represents the body of the email.
The following table describes the input/output parameters:
Parameters
Data Type
Description
Management_Param
ARRAY [0...3] OF INT
Exchange management table consisting of four words (activity, report, timeout, length) used to control parameters of the execution.
The length parameter (4th word of the management table) is an output parameter. This word is written by the system with the total length of the email (dynamic subject + body). The maximum size of the dynamic subject + body is 1 024 characters. If the size of the dynamic subject + body exceeds 1 024 characters, an incorrect send length error code is generated.
SEND_EMAIL Rules
After the launch of a SEND_EMAIL function block, the activity bit is set until the email is sent. There is no confirmation that the email has arrived to the destination address. If a timeout is programmed (third management word <> 0), the email is cancelled if it has not been sent within this time. In this case, the second management word receives an exchange stop on timeout (0x01) error code.
You may send four simultaneous emails, using four function blocks. A fifth function block trying to send an email will receive a no processor system resources (0x0B) error code until one of the resources is free.
SEND_EMAIL Example
SEND_EMAIL EF Local Error Codes
Error Code (hex)
Description
16#00
No error
16#01
Time out
16#02
User cancelled
16#03
Bad address format
16#04
Destination address incorrect
16#06
Com Fb parameters incorrect
(e.g., HEAD_KEY parameter not equal to 1, 2, or 3)
16#07
Generic transmission problem
16#09
Receive buffer too small
16#0B
No system resources: the number of simultaneous communication EFs exceeds the maximum that can be managed by the processor
16#0E
Incorrect send length
NOTE: The SEND_EMAIL EF local error codes provide more information than the Ethernet channel diagnostic information (in the Control Expert Debug screen). For example, when the message body is greater than allowed, the email is truncated and sent. Whereas, with the Ethernet diagnostic, there is no error, while the EF displays the code 16#0E.