FB_SmtpAttach

The function block FB_SmtpAttach sends a data stream to a remote ADS device via ADS. The TwinCAT ADS SMTP service must be running on the remote ADS device so that the data stream can be received and processed into an email. As soon as the data stream has been processed, the email is sent.
Inputs
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 *)
sAttachments : ARRAY [0..32] OF STRING;
bExecute : BOOL;
tTimeout : TIME := T#20s;
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetID | AmsNetID on which the TwinCAT SMS server is running. |
sSmtpServer | T_MaxString | Name or IP of the SMTP server |
sUsername | T_MaxString | User name of the SMTP server |
sPassword | T_MaxString | Password for the SMTP server |
nAuth | UDINT | Smtp Auth Type: |
sFrom | T_MaxString | A string containing the email address of the sender. The sender must be specified. The string is limited to 255 characters. |
sTo | T_MaxString | A string containing the recipient's email address. At least one recipient must be entered. It is also possible to enter multiple addresses. These must be separated by a semicolon. The string is limited to 255 characters. |
sCc | T_MaxString | A string containing the email addresses of additional recipients (cc=carbon copy). It is possible to enter multiple recipient addresses. 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 | T_MaxString | A string containing the email addresses of additional recipients (Bcc = blind carbon copy). It is possible to enter multiple recipient addresses. 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. |
sSubject | T_MaxString | 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: CX00762C"). The subject line string is limited to 255 characters. |
pMessage | DWORD | 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 specified with the ADR operator. |
cbMessage | UDINT | Length of the email text. The length can be specified by the LEN operator. |
bExecute | ARRAY [0..32] OF STRING | The function block is enabled by a rising edge on this input variable. |
sAttachments | BOOL | Listing of file names |
tTimeout | TIME | The maximum time allowed to execute a command. |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | The output variable remains TRUE until the function block has executed a command, but only until tTimeOut has expired. |
bError | BOOL | The output variable is switched to TRUE as soon as an error occurs during the execution of the command. The command-specific error is contained in iErrorId. |
nErrId | UDINT | 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 |