public List <SystemTestResult> Execute(SystemTestCategories systemTestCategory) { var results = new List <SystemTestResult>(); MailMessage mailMessage = new MailMessage() { Subject = "Test email", Sender = new MailAddress(Globals.EngineeringEmailAddress), From = new MailAddress(Globals.EngineeringEmailAddress), Body = "Test email", IsBodyHtml = false, }; mailMessage.To.Add(new MailAddress(Globals.EngineeringEmailAddress)); try { IEmailConnection emailConnection = EmailUtilities.GetEmailConnection(_applicationConfiguration); emailConnection.SendEmail(mailMessage); results.Add(new SystemTestResult(SystemTestResult.ResultTypes.Warning, _category, "Email test OK.", "")); // Email passed to server, we don't know for certain that it will arrive } catch (System.Exception exception) { results.Add(new SystemTestResult(SystemTestResult.ResultTypes.Warning, _category, String.Format("Error sending test email: {0}. Notifications will not work. Please check the configuration.", exception.Message), "")); } return(results); }
public void Insert(AuditEvent auditEvent) { IAuditEventEmailCreator emailCreator = _emailCreators.Where(ec => ec.Handles(auditEvent)).FirstOrDefault(); if (emailCreator != null) { MailMessage mailMessage = emailCreator.CreateEmail(auditEvent); if (mailMessage != null) { _emailConnection.SendEmail(mailMessage); } } }