FB_SmtpV2

FB_SmtpV2 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.

VAR_INPUT

VAR_INPUT
     sNetId     : T_AmsNetID; (* AmsNetID *)
     sSmtpServer : T_MaxString; (* Smtp Server addres ( IP or Name) *)
     sUsername     : T_MaxString; (* Smtp Username *)
     sPassword     : T_MaxString; (* Smtp Password *)
     nAuth     : UDINT;     (* Smtp Auth Type *)
     sFrom     : T_MaxString; (* Sender stzring *)
     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 in byte to send *)
     bExecute     : BOOL;
     tTimeout     : TIME := T#20s;
END_VAR

sNetId: AmsNetID on which the TwinCAT Smtp server runs.

sSmtpServer: Name or IP of the Smtp server.

sUsername: Username for the Smtp Server.

sPassword: Password for the Smtp Server.

nAuth: Smtp Auth Type:
0 = AUTH NONE
1 = RESERVED
2 = AUTH LOGIN
3 = AUTH NTLM
4 = AUTH PLAIN

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 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_SmtpV2 2:

Make sure, that you don't use \o within byte-arrays. Otherwise the Message will be cut.

The maximum amount of characters, that can be used in a message, is 510.725 - you have 1275 characters for From, To, Cc, Bcc and Subject.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v3.0.0

PC or CX (x86)

Tc2_Smtp