public IActionResult Contact(Contact model) { if (ModelState.IsValid) { _mailService.SendMail("*****@*****.**", "*****@*****.**", "Hello There", "Hello how are you!"); ModelState.Clear(); return(RedirectToAction("Index")); } return(View()); }
public IActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { var email = Startup.Configuration["AppSettings:SiteEmailAdress"]; if (string.IsNullOrWhiteSpace(email)) { ModelState.AddModelError("", "Could not send Email, Server Configuration problem"); } if (_mailService.SendMail(email, email, $"Contact Page from {model.Name} ({model.Email})", model.Message)) { ModelState.Clear(); ViewBag.Message = "Mail Sent, Thanks!"; } ; } return(View()); }