public ActionResult Contact(ContactEmailModel model) { if (ModelState.IsValid) { try { String subject = model.Subject; String contents = model.Contents; ContactEmail es = new ContactEmail(); es.Send(subject, contents); ViewBag.Result = "Email has been send."; ModelState.Clear(); return(View(new ContactEmailModel())); } catch { return(View()); } } return(View()); }
public ActionResult Contact(ContactFormModel cfm) { try { if (this.ModelState.IsValid) { ContactEmail email = new ContactEmail() { FirstName = cfm.FromFirstName, LastName = cfm.FromLastName, EmailFrom = cfm.FromEmail, EmailTo = ConfigurationManager.AppSettings["EmailTo"], SmtpFrom = ConfigurationManager.AppSettings["SmtpFrom"], Subject = cfm.Subject, Message = cfm.Message }; email.Send(); return RedirectToAction("Index"); } } catch (RulesException ex) { this.ModelState.AddRuleErrors(ex); } return View(cfm); }
public IActionResult Contact(ContactEmailViewModel model) { if (ModelState.IsValid) { //attempt to send email and show pop-up to user if successfull var recepients = dbContext.RequestEmailRecepients.ToList(); var contactEmail = new ContactEmail(model.FullName, model.EmailAddress, model.CurrentMember, model.Comments, recepients); bool result = contactEmail.Send(); return(Json(new { success = result })); } else { return(Json(new { success = false })); } }