TagSendMessageToFB Function Block

Help Contents


The TagSendMessageToFB Function Block sends a message to a recipient using an SMTP Connector tag.

The function block sends the message by sending a SendMessageTo tag command to the tag. The function block provides status information to:

If you are planning to use TagSendMessageToFB Function Block to send messages about abnormal conditions, consider using the Alarm Router Tag instead. The Alarm Router Tag can automatically forward alarms as email messages. Using the Alarm Router Tag you can configure:

Functions and Function Blocks

The TagSendMessageToFB Function Block is intended for use in a Program Tag that runs on the Fernhill SCADA Server. A Program Tag uses a continuous execution model, where the program code runs at a fixed interval. The function block samples the state of the tag command as it executes.

To send a message from an Operator Action, use the TagSendMessageTo Function.


The TagSendMessageToFB Function Block has this syntax:

        ERRORMSG=>Variable-Reference );

Note: All parameters are optional.


The TagSendMessageToFB Function Block has these parameters:

Parameter Type Direction Description
REQ BOOL R_EDGE Input A rising edge starts the SendMessageTo Tag Command.
TAGNAME WSTRING Input The name of SMTP Connector tag to send the SendMessageTo Tag Command to. For more information see TAGNAME Parameter in the remarks section.
RECIPIENT WSTRING Input The address of the recipient who will receive the message.
SUBJECT ANY_STRING Input The subject line of the message.
MESSAGE ANY_STRING Input The message text. Note: In Fernhill SCADA, IEC 61131-3 Strings are limited to a maximum of 65535 characters. For this reason, the maximum length of message you can send using this function block is limited to 65535 characters.
BUSY BOOL Output Set to TRUE while the SendMessageTo Tag Command is in progress.
DONE BOOL Output Set to TRUE for 1 execution after the SendMessageTo Tag Command has completed.
ERROR BOOL Output Set to TRUE if the SendMessageTo Tag Command failed.
ERRORMSG WSTRING Output If ERROR is TRUE, the reason why the SendMessageTo Tag Command failed.


TAGNAME Parameter

The TAGNAME parameter is the full name of the tag that runs the SendMessageTo Tag Command. The value of this parameter can be an absolute tag name or a relative tag name. A relative name tag name is resolved relative to the program tag that runs the function block.

The tag should be one of the types listed in the Applies To list of the SendMessageTo Tag Command.

Timing Diagram

Once the SendMessageTo Tag Command begins, additional requests from the input signal REQ are ignored until the tag command completes.

These timing diagrams show the relationship of the REQ, BUSY, DONE, and ERROR signals processing two requests. The first request completes with an error, the second request completes normally:

        +--------+     +-+ +------+
  REQ   |        |     | | |      |
      --+        +-----+ +-+      +------

        +------+       +------+
 BUSY   |      |       |      |
      --+      +-------+      +----------

               ++             ++
 DONE          ||             ||

ERROR          |       |
      ---------+       +-----------------

The BUSY signal is TRUE while the tag command is in progress. The DONE signal is TRUE for 1 execution after the completion of the tag command.

Debug a Function Block

To monitor the state of a function block as it executes:

  1. Open the program in the Configuration Tool.
  2. Right click the program editor and select Watch Global Variables.
  3. Expand the variables on the left until the function block member variables are visible.

Use the ERROR and ERRORMSG member variables to check the tag command is executed correctly.


  1. Send a message to a user when a digital data point tag changes to TRUE:
    Program MAIN
            (* The function block declaration *)
            SendMsgFB : TagSendMessageToFB;
            (* The tag used to trigger the write operation
               Note: Uses a relative tag reference to 'Digital Trigger Tag' 
                     located in the same folder as this program *)
            TriggerTag AT %".Digital Trigger Tag" : BOOL;
        (* Call the TagSendMessageToFB function block *)
            TAGNAME:="SMTP Connector Tag",
            SUBJECT:='Operator Alert',
            MESSAGE:='Something has occurred which needs your attention!' );
        (* The DONE output is active for one cycle when the function block completes *)
        IF SendMsgFB.DONE THEN
            (* Was there an error ? *)
            IF SendMsgFB.ERROR THEN
                (* Handle any error *)
                (* Any additional work on successful completion *)

The following IEC 61131-3 Program shows:

Further Information

SendMessageTo Tag Command

To learn about the SendMessageTo Tag Command.

Tag Command Function Blocks

To learn about other tag command function blocks.

IEC 61131-3 Expressions

To learn about the different types of expression to use as function parameters.

Elementary Data Types

To learn about the different types supported by Fernhill SCADA.

Common Elements

To learn about other IEC 61131-3 Common Elements.


For the meaning of terms used in Fernhill SCADA.