Chapter5.OPC to Email and SMS

Table of Contents

5.1. Introduction
5.1.1. How it works
5.1.2. A note about SMS text messages
5.2. Configuring the Mail Server
5.3. Sending a Test Message
5.4. Defining the Email Message
5.5. Assigning a Trigger
5.6. Setting Trigger Conditions
5.7. Configured Actions
5.8. HTML Message Examples
5.8.1. An HTML Message with Embedded Data Points
5.8.2. An HTML Message with a Table Created in Code
5.9. How to Send SSL-encrypted Email


The OPC DataHub lets you send emails and SMS text messages, triggered by a DataHub event such as a point value change, or by a timer. The emails and messages can be in plain text or HTML format, and they can contain current values for any data point in the DataHub

With this feature of the DataHub you can:

    Send SMS text messages to cell phones when an alarm event is triggered.

    Design end-of-day reports that are delivered to managers' email accounts each morning.

    Provide managers with regular email updates of production targets.

    Emails can contain data from OPC servers, ODBC databases and other sources.

    Eliminate errors associated with manually writing production reports.

    Have the DataHub collect vital report information, format it as an Excel spreadsheet and then email the file to key people for review.

5.1.1.How it works

The DataHub mailer uses a public data domain mailing program called Blat. DataHub scripts tell Blat what messages to send and to whom, and they control when Blat sends them. The script BlatSupport.g contains all the setup instructions necessary to get Blat running. This script is not usually edited except possibly to modify the Blat installation.

Any other script can start up Blat by including this line:

require ("BlatSupport.g")

In addition to this line, a typical mailing script contains instructions to send an email in plain text, HTML format using ASP, or both. The example script, MailTest.g contains examples of both methods. You can run this script to test the mailer, and then use the examples that follow to send your own messages.

The sections in this chapter show you how to:

5.1.2.A note about SMS text messages

Sending SMS text messages from the DataHub is done by simply sending a small plain text email to the appropriate SMS gateway email address. Most cell phone service providers offer email and text messaging options on new subscriptions.

For example, if you subscribed with Bell Mobility in Canada, and your new cell phone number was (416) 123 4567, then the email address for this phone would be:

and the SMS text message address would be slightly different:

Normally, SMS text messages are sent from one cell phone to another, which is all handled within the cell network itself. Using the SMS text message address, you can send a regular email and it will be converted by the SMS gateway ( in the example) into a text message and be delivered to your phone. There may be a short delay while the conversion from email to text message occurs, but the message usually arrives in less than a minute.

Check with your cell phone service provider for the SMS text message address for your cell phone number.