[ValidateAntiForgeryToken] // prevent cross-site request forgery attacks public ActionResult SubmitForm(SubmitFormAjax model) { if (ModelState.IsValid) { SendEmail(model); return(PartialView(PARTIAL_VIEW_FOLDER + "_FormSuccess.cshtml")); } return(PartialView(PARTIAL_VIEW_FOLDER + "_FormError.cshtml")); }
private void SendEmail(SubmitFormAjax model) { MailMessage message = new MailMessage(model.EmailAddress, "*****@*****.**"); message.Subject = string.Format("De la {0} {1} - {2}", model.FirstName, model.LastName, model.EmailAddress); message.Body = model.Message; SmtpClient client = new SmtpClient("127.0.0.1", 25); client.Send(message); }