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); } } }
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); } }