Ejemplo n.º 1
0
        public ActionResult Contacto(ContactoModel model)
        {
            var fromAddress = new MailAddress("*****@*****.**");
            var fromPassword = "******";
            var toAddress = new MailAddress("*****@*****.**");

            string subject = "Consulta desde la pagina" + model.UserName;
            string body = model.UserEmail + "/r/n" + model.Texto;

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)

            };

            using (var message = new MailMessage(new MailAddress(model.UserEmail, model.UserName), toAddress)
            {

                Subject = subject,
                Body = body
            })

                smtp.Send(message);
            return RedirectToAction("Lista", "Articulos", null);
        }
Ejemplo n.º 2
0
 public ActionResult Contacto()
 {
     ContactoModel model = new ContactoModel();
     return View(model);
 }