Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info

Download the Solution Example here: AlarmEmailAndSMS.dbsln


  • Solution Name:
AlarmEmailAndSMS
  • Alarm Email and SMS
  • Software Version:
10.0.6
  • v10
  • Keywords: Alarms
. Notifications. Email. SMS.
  • , Notifications, Method

Summary

This sample demonstrates configuring how to configure the system to send an email and an SMS containing alarm information using the feature NotificationMethod every time with alarm details whenever an alarm event occurs, using the NotificationMethod feature.

Image Added


Technical Information

The NotificationMethod used in this solution example allows configuring your solution to send an email, an SMS, a message box, or speech the alarm message every time a conditional event alarm occurs. 

When the solution runs, the NotificationMethod is called every time a conditional event alarm occurs. Then, this method receives an Array of AlarmEventInfo as a parameter. The NotificationMethod must follow the prototype See an example code below:

Code Block
languagec#
public void NotificationMethodAlarmEvents(AlarmEventInfo[] events)

{

    //Protection in case events its null
    if (events == null)
        return;

    //Get the first event
    AlarmEventInfo event = events[0];
    if (event.State != 1)
        return;

    //Get information about the alarm event to create the body of the email
    string body = "Time: " + event.ActiveLocalTime.ToString() + "\n" +
    "Message = " +  event.Message + "\n" +
    "Area = " + event.Area + "\n" +
    "Group = " + event.Group + "\n" +
    "Tag = " +  event.TagName + "\n";


    //Code to send email           
    try
    {
        //Configuring the SMTP Client
        System.Net.Mail.SmtpClient mySmtpClient = new System.Net.Mail.SmtpClient(@Tag.smtpServer, 587);
        mySmtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
        mySmtpClient.EnableSsl = true;
        mySmtpClient.UseDefaultCredentials = false;
        mySmtpClient.Credentials = new System.Net.NetworkCredential(@Tag.fromEmail, @Tag.passFromEmail);

        //Sending the email
        mySmtpClient.Send(@Tag.fromEmail, @Tag.toEmail, "Dmail notification", body);
    }

    catch (Exception ex)
    {
        @Info.Trace("Error sending message: " + ex.Message);
    }
}

Once in the NotificationMethod, you can send an email, send a message, send a message box, speech an alarm message, etc.


Reference Information

→ See Alarms for more information.


In this section:

Page Tree
root@parent
spacesV10

Reference Information

If sending emails is required in your solution, you can install a PlugIn with that functionality.

See Alarms for more information.