public ActionResult Contact(Contact contact) { if (!ModelState.IsValid) { return View(contact); } new Email().Send(contact); return RedirectToAction("ContactConfirm"); }
public void Send(Contact contact) { var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential("*****@*****.**", "laughingduck") }; var mail = new MailMessage( contact.Email, "*****@*****.**", "DR Murals- New message from " + contact.Name, contact.Comment); smtp.Send(mail); }