- Solution Name: Alarm Email and SMS
- Software Version:
- v10
- Keywords: Alarms, 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.
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:
Code Block | ||
---|---|---|
| ||
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:
Page Tree | ||||
---|---|---|---|---|
|