FB_SmtpV3_Full
This function block communicates with the TwinCAT SMTP Server via ADS. It offers very extensive email functionalities, such as prioritizing emails from the PLC. The individual parameters are explained in detail in this documentation.
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 *)
nEncryption : UDINT; (* 0=NONE, 1=STARTTLS, 2=TLS*)
sFrom : T_MaxString; (* Sender stzring *)
sTo : T_MaxString; (* To recipient string *)
sCc : T_MaxString; (* Cc recipient string *)
sBcc : T_MaxString; (* Bcc recipient string *)
sDispositionNotification: T_MaxString; (* Disposition notification recipent string *)
sReturnReceipt : T_MaxString; (* Return recipent string *)
nPriority : UDINT; (* Priority value *)
nSensitivity : UDINT; (* Sensitivity value *)
nPort : UDINT; (* Communication port *)
nContentType : UDINT; (* Content type *)
sSubject : T_MaxString; (* Subject string *)
pMessage : POINTER TO STRING; * Pointer to the message *)
cbMessage : UDINT; (* Message lenght in byte to send *)
sAttachments : ARRAY [0..32] OF STRING; (* Different attachments *)
bExecute : BOOL; (* Trigger flag *)
tTimeout : TIME := T#20s; (* Communication timeout *)END_VAR
sNetId: AmsNetID on which the TwinCAT SMTP server is running.
sSmtpServer: name or IP of the SMTP server to be reached.
sUsername: user name of the SMTP server to be reached.
sPassword: password for the SMTP server to be reached.
nEncryption: SMTP encryption type:
0 = NONE
1 = STARTTLS
2 = TLS
sFrom: a string containing the email address of the sender. The sender must be specified. The string is limited to 255 characters.
sTo: a string containing the email address of the recipient. At least one recipient must be entered. However, it is also possible to enter multiple addresses. These must be separated by a semicolon. The string is limited to 255 characters.
sCc: a string containing the email address of additional recipients (cc=carbon copy). It is possible to enter multiple addresses of recipients, these must then be separated by a semicolon. However, the string can also remain empty. A copy of the email will be sent to the recipient(s). The recipient's email address is visible to other recipients. The string is limited to 255 characters.
sBcc: a string containing the email addresses of additional recipients (Bcc = blind carbon copy). It is possible to enter multiple addresses of recipients, these must then be separated by a semicolon. However, the string can also remain empty. A copy of the email will be sent to the recipient(s). The recipients' email address is not visible to other recipients. The string is limited to 255 characters.
sDispositionNotification: the email address specified here, receives a read notification from the recipients of sTo and sCc. However, the prerequisite for this is that it is also sent by the recipients.
sReturnReceipt: a transfer confirmation of the sent email is sent to the email address specified here.
nPriority: with this parameter you can set the priority of the email:
1 = Highest
2 = not used
3 = Normal
4 = not used
5 = Lowest
nSensitivity: with this parameter you can set the confidentiality of the message:
0 = Private
1 = Personal
2 = Normal
3 = Confidential
nPort: here you can select the communication port. If you do not enter your own port, the default port 25 is used.
nContentType: this parameter makes it possible, for example, to make HTML code, which is passed to the function block by pointer (pMessage) and size (cbMessage) of a string variable, readable in the email.
sSubject: this string contains the subject of the email. If the email is sent without a subject, the computer name of the sender is automatically written in the subject line (e.g. "Email sent by: CX-00762C"). The subject line string is limited to 255 characters.
pMessage: this parameter specifies the address of the string containing the message text. If the email is sent without text, the date and time will be inserted automatically (e.g. "Mail send 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 email text. The length can be specified by the LEN operator.
bExecute: the function block is enabled by a rising edge at this input variable.
sAttachments: list of attachments (path and file name) to be sent.
tTimeout: the allowed maximum time to execute a command.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
bBusy: the output remains TRUE until the function block has executed a command, but only until tTimeOut has expired.
bError : the output is switched to TRUE as soon as an error occurs during the execution of the command. The command-specific error is contained in nErrId.
nErrId: contains the command-specific error code of the most recently executed command (see table).
![]() | 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 |