private static void SendEmailToTeamWhenFailToSendEmailOnOrder(object sender, AsyncCompletedEventArgs e) { var emailModel = new DPO.Common.SendEmailModel(); SendEmailModel sendEmailModel = emailModel; List <string> fromEmails = Utilities.Config("dpo.sys.email.orderSendEmailError").Split(',').ToList(); emailModel.Subject = string.Format("send email Order Submit error"); emailModel.From = new MailAddress(fromEmails.First(), "Send Email Error"); foreach (string email in fromEmails) { emailModel.To.Add(new MailAddress(email, "Daikin Project Desk")); } string emailMessage = string.Format(@"An error occured when try to send email for Order Submit.Below are the Order Details: <br />" + "The below are the error details: <br /> {0}", (e.Error.InnerException != null) ? e.Error.InnerException.Message : e.Error.Message); sendEmailModel.Subject = "Order Submit Email Failure Notification."; sendEmailModel.RenderTextVersion = true; sendEmailModel.BodyTextVersion = emailMessage; new EmailServices().SendEmail(sendEmailModel); }
public ActionResult SendEmailToTeamWhenFailToSendEmailOnOrder(long quoteId, string exception) { //var emailModel = this.orderService.getOrderSendEmailModel(orderVMLight); long projectId = projectService.GetProjectId(this.CurrentUser, quoteId); ProjectModel projectModel = projectService.GetProjectModel(this.CurrentUser, projectId).Model as ProjectModel; var emailModel = new DPO.Common.SendEmailModel(); var sendEmailModel = emailModel; var fromEmails = Utilities.Config("dpo.sys.email.orderSendEmailError").Split(',').ToList(); emailModel.Subject = string.Format("An Order has been submitted"); emailModel.From = new MailAddress(fromEmails.First(), "Send Email Order Submit Error"); foreach (string email in fromEmails) { emailModel.To.Add(new MailAddress(email, "Daikin Project Desk")); } string emailMessage = string.Format(@"An error happned when try to send email for Order Submit.Below is the Order Details:" + Environment.NewLine + "Project Reference: {0} " + Environment.NewLine + "Project Date: {1} " + Environment.NewLine + "Project Owner: {2} " + Environment.NewLine + "Quote Reference: {3} " + Environment.NewLine + "Exception Details: {4}", projectModel.ProjectId.ToString(), projectModel.ProjectDate, projectModel.OwnerName, quoteId.ToString(), (exception != string.Empty) ? exception : Session["SavePoAttachment"].ToString()); sendEmailModel.Subject = "Order Submit Send Email has error"; sendEmailModel.RenderTextVersion = true; sendEmailModel.BodyTextVersion = emailMessage; try { new EmailServices().SendEmail(sendEmailModel); } catch (Exception ex) { log.ErrorFormat("sending Order submit error email failed.", ex.InnerException.Message); } return(null); }