public async Task <ActionResult> SendMessage(ContactViewModel contactForm) { if (!ModelState.IsValid) { return(RedirectToAction("Index", "Contact")); } var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); // replace with valid value message.From = new MailAddress(contactForm.Email); // replace with valid value message.Subject = "Contact Form - Question"; message.Body = string.Format(body, "User", contactForm.Email, contactForm.Text); message.IsBodyHtml = true; try { await _emailManager.EmailSenderAsync(message); } catch (Exception e) { return(RedirectToAction("Contact", "EmailError")); } return(RedirectToAction("Index", "Post")); }