TagSendMessageTo -Send a Message to a Recipient

Help Contents

Introduction

The TagSendMessageTo function block sends a message with a subject line to a recipient.

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

The TagSendMessageTo function block is intended for use with:

If you are planning to use TagSendMessageTo 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:

Parameters

The TagSendMessageTo 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.
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.
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.

Remarks

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.

Example Program

The following IEC 61131-3 Program shows:

  1. A FALSE to TRUE transition of a digital data point tag used to trigger a function block.
  2. The function block sending a message with a subject line to a SMTP Connector tag.
  3. Example logic to check the status of the function block.
Program MAIN
    VAR 
        (* The function block declaration *)
        SendMsgFB : TagSendMessageTo;

        (* 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;
    END_VAR

    (* Call the TagSendMessageTo function block *)
    SendMsgFB( 
        REQ:=TriggerTag,
        TAGNAME:="SMTP Connector Tag",
        RECIPIENT:="user@workplace.com",
        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 *)
        ELSE
            (* Any additional work on successful completion *)
        END_IF;
    END_IF;

END_PROGRAM

Further Information

SendMessageTo Tag Command

To learn about the SendMessageTo tag command.

Tag Command Function Blocks

To learn about other tag command function blocks.

Elementary Data Types

To learn about the different types supported by Fernhill SCADA.

Common Elements

To learn about other IEC 61131-3 Common Elements.

Glossary

For the meaning of terms used in Fernhill SCADA.