You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Next »

Download the Solution Example here: AlarmEmailAndSMS.dbsln

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

Summary

This sample demonstrates configuring to send an email and an SMS containing alarm information using the feature NotificationMethod every time an alarm event occurs.


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. See an example code below:

public void AlarmEvents(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

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

→ See Alarms for more information.


In this section:

The root page @parent could not be found in space v10.

  • No labels