示例#1
0
        static void SendEmail(string subject, string body)
        {
            SmtpClient client = new SmtpClient {
                Host                  = SMTPHost,
                Port                  = SMTPPort,
                EnableSsl             = true,
                Timeout               = 10000,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(Address, Password)
            };

            using (MailMessage mail = new MailMessage(Address, Address, subject, body)
            {
                BodyEncoding = Encoding.UTF8,
                DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
            }) {
                try {
                    client.Send(mail);
                } catch {
                    LogViewer.Log("Failed to send e-mail alert.");
                    Program.window.LastAlert.Text = LogViewer.GetLog(1);
                }
            }
        }
示例#2
0
 public static void SendAlert(Room room, string message)
 {
     if (room != null)
     {
         room.BackColor = Color.Red;
     }
     if (Program.window != null)
     {
         SendEmail("Remote Monitoring Alert", message);
         LogViewer.Log(message);
         Program.window.LastAlert.Text = LogViewer.GetLog(1);
     }
     else
     {
         MessageBox.Show(message);
     }
 }