/// <summary> /// Sends a previously audited e-mail. /// Returns true if sending succeeds, false otherwise. /// </summary> public static bool ResendEmail(EmailAuditDal emailAuditDal) { MailMessage message = emailAuditDal.CreateMailMessage(); SmtpClient smtpClient = new SmtpClient(); bool isMailSent = false; // Try to send the mail. try { emailAuditDal.DateSent = System.DateTime.Now; smtpClient.Send(message); // When the send succeeds set the status to send and set the time and date. emailAuditDal.EmailStatus = EmailStatus.Sent; emailAuditDal.StatusMessage = "Opnieuw verzonden na eerdere fout bij verzenden."; isMailSent = true; } catch (SmtpException e) { // When sending the mail fails set the status to sendError and set the status message. emailAuditDal.EmailStatus = EmailStatus.SendError; emailAuditDal.StatusMessage = e.Message; } finally { emailAuditDal.Save(); } return isMailSent; }