Function Description

The SEND_EMAIL function is used for sending an email with a Modicon M340.

The SEND_EMAIL service is limited to the embedded Ethernet port and the BMX NOC 0401 modules. It is not supported through a BMX NOE module.

NOTE: For the SEND_EMAIL service to function properly, the IP address of the SMTP server and usable email destinations must first be configured in the Control Expert software.

The additional parameters EN and ENO can be configured.

FBD representation

Representation:

LD representation

Representation:

IL representation

CAL SEND_EMAIL (ADR := Channel_Address, HEAD_KEY := Header_Number, SUBJ_STR := Str_Email_Subject, BODY_STR := Str_Email_Body, GEST := Management_Param);

ST representation

SEND_EMAIL (ADR := Channel_Address, HEAD_KEY := Header_Number, SUBJ_STR := Str_Email_Subject, BODY_STR := Str_Email_Body, GEST := Management_Param);

Parameter Description

The following table describes the input parameters:

Parameter

Type

Description

Channel_Address

ARRAY [0..7] OF INT

Address or result of the ADDM. It uses ADDM EF to build this field.ADDM Function

To send an email through a CPU Ethernet port, use ADDM(‘0.0.3’).

To send an email through a BMX NOC module configured at rack 0, slot 4, channel 0, use ADDM(‘0.4.0’).

Header_Number

INT

Corresponds to the emails addresses handled with Control Expert software (only 1, 2, 3 are accepted).

Str_Email_Subject

STRING

Represents the dynamic part of the subject that is appended to the static subject string.

Str_Email_Body

STRING

Represents the body of the email.

The following table describes the input/output parameters:

Parameter

Type

Comment

Management_Param

ARRAY [0..3] OF INT

Exchange management table.

4-word table 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 (header + body). The maximum size of header + body is 1024 characters.

Send Email Rules

After the launch of a SEND_EMAIL EF, the activity bit is set until the mail is sent. However, there is no confirmation that the mail arrived at the destination. If a timeout is programmed (3rd management word <> 0), the mail is canceled if it has not been sent during the programmed time.In this case, the 2nd management word receives a negative response Exchange stop on timeout (0x01).

Run-time characteristics : the Modicon M340 system is able to manage four simultaneous send requests, coming from four EFs. A 5th EF trying to send an email will get the information No processor system resources (0x0B) until one of the resources is free.

Send Email Service Example

IF (default_id = 0) and FE(default_state) THEN 
   (* PUMP IS OK *)
   SEND_EMAIL(ADDM('0.0.3'), 1, 'Pump n°3 is OK', ' ' , Management_Param);
ELSEIF RE(default_state) THEN
   (* PUMP IS FAULTY *)
   str_default := INT_TO_STRING(default_id); 
   str_Email_Body := CONCAT_STR(' Default = ', str_default);
   SEND_EMAIL(ADDM('0.0.3'), 1, 'Pump n°3 is faulty', str_Email_Body, Management_Param);
END_IF;