FB_Smtp

FB_Smtp 1:

The block sends a byte stream to a remote ADS device via ADS. The TwinCAT ADS Smtp service must be running on the remote ADS device, so that the byte stream can be received and processed into an e-mail. Once the byte stream has been processed the e-mail is sent.
Note that password checking must be disabled on the SMTP server, since the TwinCAT ADS Smtp service does not register on the server via password checking.

VAR_INPUT

VAR_INPUT
    sNetId          : T_AmsNetID;   (* AmsNetID *)
    sSmtpServer     : T_MaxString;  (* Smtp-Server address (IP or Name) *)
    sFrom           : T_MaxString;  (* Sender string *)
    sTo             : T_MaxString;  (* To recipient string *)
    sCc             : T_MaxString;  (* Cc recipient string *)
    sBcc            : T_MaxString;  (* Bcc recipient string *)
    sSubject        : T_MaxString;  (* Subject string *)
    pMessage        : DWORD;       (* Pointer to the message *)
    cbMessage       : UDINT;       (* Messagelenght to send *)
    bExecute        : BOOL;
    tTimeout        : TIME := T#20s;
END_VAR

sNetId: AmsNetID on which the TwinCAT SMS server runs.

sSmtpServer: Name or IP of the Smtp server.

sFrom: A string containing the e-mail address of the sender. A sender must be specified. The string is limited to 255 characters.

sTo: A string containing the e-mail address of the recipient. Several addresses can be specified, separated by semicolon. At least one recipient has to be specified. The string is limited to 255 characters.

sCc: A string containing an e-mail address of a further recipient (cc=carbon copy). This string can also be empty. A copy of the e-mail is sent to this recipient. The e-mail address of this recipient is visible to other recipients. It is possible to enter multiple recipient addresses separated by semicolons. The string is limited to 255 characters.

sBcc: A string containing the e-mail address of a further recipient (Bcc = blind carbon copy). This string can also be empty. A copy of the e-mail is sent to this\these recipient\s. The e-mail address of this recipient is not visible to other recipients. It is possible to enter multiple recipient addresses separated by semicolons. The string is limited to 255 characters.

sSubject: A string containing the subject line for the e-mail. The e-mail may be sent without subject, in which case the name of the sending computer is automatically entered in the subject line (e.g. "Mail sent from: CX_00762C"). The string for the subject line is limited to 255 characters.

pMessage: The address (a pointer) to a null-terminated string containing the e-mail text. The e-mail may be sent without body text, in which case the date and time are entered automatically (e.g. "Mail sent at: Thu, 23 Mar 2006 02:31:44 -0800"). The address of the string can be determined with the ADR operator.

cbMessage: Length of the e-mail text. The length can be determined through the LEN operator.

bExecute: The function block is activated by a rising edge at this input.

tTimeout: Maximum time allowed for the execution of the command.

VAR_OUTPUT

VAR_OUTPUT
    bBusy   : BOOL;
    bError  : BOOL;
    nErrId  : UDINT;
END_VAR

bBusy: this output remains TRUE until the function block has executed a command, but at the longest for the duration supplied to the tTimeOut input.

bError: this output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in iErrorId.

nErrId: contains the command-specific error code of the most recently executed command (see table).

FB_Smtp 2:
  • Make sure that you have no \0 digits within the byte array, because the message will be aborted there.
  • The maximum number of characters that may be used in a message is 510,725 - 1275 characters are available for From, To, Cc, Bcc and Subject.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v2.8.0 and above

 

TcSmtp.lib