public virtual ActionResult ContactUs(ContactUsViewModel contactForm) { if (!ModelState.IsValid) { return(View("~/Views/Pages/ContactUs.cshtml", contactForm)); } var from = new MailAddress(contactForm.Email); var message = @" ### Contact Name: {0} {1} Email: {2} Phone: {3} Company: {4} ### Message {5} ".format_with(contactForm.FirstName, contactForm.LastName, contactForm.Email, contactForm.PhoneNumber, contactForm.CompanyName, contactForm.Message); messageService.ContactUs(from, contactForm.MessageTo, message, contactForm.CompanyName); TempData["Message"] = "Your message has been sent."; return(View("~/Views/Pages/Thanks.cshtml")); }
public virtual ActionResult ContactUs(ContactUsViewModel contactForm) { if (!ModelState.IsValid) { return(View("~/Views/Pages/ContactUs.cshtml", contactForm)); } if (!string.IsNullOrWhiteSpace(contactForm.Email) && contactForm.Email.EndsWith("qq.com")) { ModelState.AddModelError(string.Empty, "Please use an alternative email address. This domain is known to send spam."); return(View("~/Views/Pages/ContactUs.cshtml", contactForm)); } var from = new MailAddress(contactForm.Email); var message = @" ### Contact Name: {0} {1} Email: {2} Phone: {3} Company: {4} ### Message {5} ".format_with(contactForm.FirstName, contactForm.LastName, contactForm.Email, contactForm.PhoneNumber, contactForm.CompanyName, contactForm.Message); var additionalSubject = contactForm.CompanyName; if (string.IsNullOrWhiteSpace(additionalSubject)) { additionalSubject = "{0} {1}".format_with(contactForm.FirstName, contactForm.LastName); } messageService.ContactUs(from, contactForm.MessageTo, message, additionalSubject); TempData["Message"] = "Your message has been sent. You may receive follow up emails from '{0}', so make any necessary adjustments to spam filters.".format_with(Configuration.ReadAppSettings("ContactUsEmail")); return(View("~/Views/Pages/Thanks.cshtml")); }
public virtual ActionResult ContactUs(ContactUsViewModel contactForm) { if (!ModelState.IsValid) return View("~/Views/Pages/ContactUs.cshtml", contactForm); var from = new MailAddress(contactForm.Email); var message = @" ### Contact Name: {0} {1} Email: {2} Phone: {3} Company: {4} ### Message {5} ".format_with(contactForm.FirstName, contactForm.LastName, contactForm.Email, contactForm.PhoneNumber, contactForm.CompanyName, contactForm.Message); messageService.ContactUs(from, contactForm.MessageTo, message, contactForm.CompanyName); TempData["Message"] = "Your message has been sent."; return View("~/Views/Pages/Thanks.cshtml"); }