Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Overview

The library contains useful function blocks for the BC9000 Bus Terminal Controller for use of the SMTP protocol (simple mail transfer protocol).

Function blocks

Name | Description
FB_Smtp | Sends e-mails.


FB_Smtp

TwinCAT PLC Library: SMTP BC

FUNCTION_BLOCK FB_Smtp

This function block uses the SMTP protocol (simple mail transfer protocol) to send e-mails. The function block can, for instance, be used to send errors, diagnostic information, or warnings in the form of e-mails. The recipients' addresses are passed as strings to the sTo, sCc, sBcc and sSubject input variables. The maximum string length for recipients' addresses is limited to 80 characters in order to save resources. The string with the mail text itself may, however, be longer.

VAR_INPUT

VAR_INPUT
    bStart		: BOOL;
    sSmtpServer	: STRING(15);
    sFrom		: STRING;
    sTo		: STRING;
    sCc		: STRING;
    sBcc		: STRING;
    sSubject		: STRING;
    pMail		: DWORD;
    tTimeOut		: TIME;
END_VAR

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

sSmtpServer: IP address of the SMTP server as a string.

sFrom: A string containing the e-mail address of the sender. If the string supplied is empty, then the Bus Controller generates an e-mail address from the name of the Bus Controller and the MAC ID. The maximum string length is limited to 80 characters. It is possible to enter multiple recipient addresses separated by semicolons.

sTo: A string containing the e-mail address of the recipient. A valid e-mail address must be given. The maximum string length is limited to 80 characters. It is possible to enter multiple recipient addresses separated by semicolons.

sCc: A string containing the 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. The maximum string length is limited to 80 characters. It is possible to enter multiple recipient addresses separated by semicolons.

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 recipient. The e-mail address of this recipient is not visible to other recipients. The maximum string length is limited to 80 characters. It is possible to enter multiple recipient addresses separated by semicolons.

sSubject: A string containing the e-mail's subject line. This string can also be empty. The maximum string length is limited to 80 characters.

pMail: The address (a pointer) to a null-terminated string containing the e-mail text. This string can also be empty. The address of the string can be determined with the ADR operator.

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

VAR_OUTPUT

VAR_OUTPUT
    bBusy		: BOOL;
    bError		: BOOL;
    iErrorId		: WORD;
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.

iErrorId: Contains the command-specific error code of the most recently executed command (table).

Error code (hex) | Description
0x8000 | SMTP server not found.
0x8001 | Resource error.
0x8002 | Socket resource error.
0x8003 | Connection fault.
0x8004 | Communication fault.
0x8005 | Rx error. Communication time exceeded.
0x8006 | Rx error. Communication fault.
0x8007 | Rx error. Frame error.
0x8008 | Communication error. Wrong response.
0x8009 | Tx error. Communication fault.
0x800A | Communication shutdown error.
0x800B | Communication timeout.
0x8010 | Invalid parameter.

Example of a call in FBD:

PROGRAM MAIN
VAR
    fbSMTP	: FB_Smtp;
    bSend	: BOOL;
    sMsg 	: STRING(100):='Test';
    bBusy 	: BOOL;
    bError 	: BOOL;
    nErrId 	: UDINT;
END_VAR

In this example, a rising edge at the bStart input sends a mail to 4 recipients.

Development environment | Target platform | PLC libraries to be linked
TwinCAT v2.7.0 and above | BC9xxx (165) firmware version >=0xB6 | TcSMTPBC.Lb6