private Dictionary<string, string> TourQuoteToDictionary(TourQuoteModel model) { try { Dictionary<string, string> replacments = new Dictionary<string, string>(); replacments.Add("#NAME#", ValueToString(model.Name)); replacments.Add("#EMAIL#", ValueToString(model.Email)); replacments.Add("#TELEPHONE#", ValueToString(model.Mobile)); replacments.Add("#MOBILE#", ValueToString(model.Mobile)); replacments.Add("#PICKUPDATETIME#", ValueToString(model.TourDate)); replacments.Add("#NOOFPERSONS#", ValueToString(model.NoOfPersons)); replacments.Add("#VEHICLE#", ValueToString(model.VehicleId)); replacments.Add("#MESSAGE#", ValueToString(model.Message)); return replacments; } catch (Exception) { throw; } }
public ActionResult TourQuote(TourQuoteModel model) { GetSelectListData(); if (ModelState.IsValid) { try { EmailSender.SendTourQuoteEmail(model); ViewBag.MessageType = MessageType.Success; ViewBag.Message = "Thank you for your enquiry, our representatives will contact you soon"; return PartialView("_TourQuoteForm"); //return Json(new { StatusCode = 200 }, JsonRequestBehavior.AllowGet); } catch (Exception) { throw; } } return PartialView("_TourQuoteForm", model); //have to do something here }
internal static void SendTourQuoteEmail(TourQuoteModel model) { MailDefinition mail = new MailDefinition(); mail.From = WebSettings.EmailUsername; mail.Subject = WebSettings.TourQuoteEmailSubject; mail.BodyFileName = WebSettings.TourQuoteEmailTemplate; mail.IsBodyHtml = true; //ListDictionary replacements = ResetLinkToDictionary(order); Dictionary<string, string> replacements = new Dictionary<string, string>(); EmailSender sender = new EmailSender(); replacements = sender.TourQuoteToDictionary(model); MailMessage message = mail.CreateMailMessage(WebSettings.AdminEmail, replacements, new System.Web.UI.Control()); EmailHandler handler = new EmailHandler(message); Thread thread = new Thread(new ThreadStart(handler.SendEmail)); thread.Start(); }