Send Mail Custom
Sending e-mails – ST – from more accounts
TESTEMAIL : BOOL :=TRUE;
HOST : STRING := 'SMTP.DOMAT.CZ';
PORT : UINT := 25;
USER : STRING := 'INFO@DOMAT.CZ';
PASSWORD : STRING := '1234';
SENDER : STRING := 'INFO@DOMAT.CZ';
RECIPIENT : STRING := 'SUPPORT@DOMAT.CZ';
SUBJECT : STRING;
MESSAGE : STRING;
IF TESTEMAIL THEN
SUBJECT := 'TEST';
MESSAGE := 'TEST EMAIL HAS BEEN SENT.';
MESSAGING.SENDMAILCUSTOM(HOST, PORT, USER, PASSWORD, SENDER, RECIPIENT, SUBJECT, MESSAGE);
TESTEMAIL := FALSE;
The function sends an e-mail in each PLC computing cycle. It is highly recommended to be used in ST code only to prevent occassional flooding of the recipient with many e-mails of the same contents. Using this function, it is possible to specify the e-mail sender account and credentials in the program (this is not possible with functions sendmail and sendmailtrig where these data are entered in the channel definition). If You want to send more than one email at the time, You have to use this block multiple times or create some sort of switcher for addresses. PLC is capable of sending one email at the certain moment, so more emails needs to be sent with gaps. The gap between emails should be at least 1 second, but ideally even more.
||reference to variable with the SMTP server name
||TCP port number where the SMTP server is listening
||reference to variable with user name used to access the SMTP server
||reference to variable with password used to access the SMTP server
||reference to variable with the communication connection definition (set in PLC properties, see below)
||reference to variable with e-mail address from which the mail is sent
||reference to variable with the recipient's address
||reference to variable with the e-mail subject
||reference to variable with the e-mail body text
||Numeric status; result of the system settings check
At each of the function calls, a e-mail is sent from the predefined from e-mail account username to the to address. The e-mail subject is taken from the subject variable, and the e-mail body from the message variable.
This function has not defined the connection parameters for the SMTP server in the Channel definition. The connection parameters must be defined in the variables which are linked to the host, port, username, and password inputs. This means that the parameters may be changed by the application program, and the user account name may be different for different e-mail messages.
Remember to coeck the SMTP server availability from the network where the PLC is running.
The output variable result indicates the result of the system settings check.
||E-mail queue full
||Error - impossible to determine the status
||Internal error - contact Domat Control System support
This function is typically used to send alarm messages. The sending of an e-mail is launched by the alarm status appearance. See the ST call above for example.