public ActionResult ProductDetails(PublicViewModel pv) { if (!ModelState.IsValid) { pv.ProductGalleries = ProductManager.GetAllProductGalleriesByProductId(pv.Product.Id); return(View(pv)); } if (Session["CompanySetting"] != null) { pv.CompanySetting = (CompanySetting)Session["CompanySetting"]; } else { pv.CompanySetting = CompanySettingsManager.GetCompanySettings(1); } FeedbackManager.InsertFeedback(pv.Feedback); try { string path = System.Web.HttpContext.Current.Server.MapPath("~/Mail/mz-email.html"); string html = System.IO.File.ReadAllText(path); html = html.Replace("{name}", pv.Feedback.Name); html = html.Replace("{mobile}", pv.Feedback.Mobile); html = html.Replace("{message}", pv.Feedback.Message); html = html.Replace("{p_name}", pv.Product.ProductName); html = html.Replace("{p_price}", pv.Product.Price.ToString()); html = html.Replace("{p_link}", Request.Url?.AbsoluteUri); html = html.Replace("{date}", DateTime.Now.ToString("dd MMM yyyy")); bool hasWords = HasBadWords(pv.Feedback.Message); if (hasWords == false) { SendEmailFromGoDaddy("MazedaMart contact us inquiry", html); } StringBuilder sb = new StringBuilder(); sb.AppendFormat("<div class=\"alert alert-success\" id=\"contactSuccess\">"); sb.AppendFormat("<strong>Success!</strong> Your message has been sent to us."); sb.AppendFormat("</div>"); //pv.EmailStatus = sb.ToString(); Session["EmailStatus"] = sb.ToString(); } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<div class=\"alert alert-success\" id=\"contactSuccess\">"); sb.AppendFormat(" <strong>Error!</strong> There was an error sending your message.{0} - {1}", ex.Message, ex.InnerException?.Message); sb.AppendFormat("<span class=\"font-size-xs mt-sm display-block\" id=\"mailErrorMessage\"></span>"); sb.AppendFormat("</div>"); //pv.EmailStatus = sb.ToString(); Session["EmailStatus"] = sb.ToString(); } return(Redirect("/Home/ProductDetails/" + pv.Product.Id)); }