public ActionResult GuardarContacto(string nombre, string apellidos,string correo, string mensaje)
{
try
{
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
mailMessage.From = new System.Net.Mail.MailAddress("tucorreo@hotmail.com");
mailMessage.To.Add(correo);
mailMessage.Subject = "Tu solicitud ha sido recibida.";
mailMessage.Body = "En brevedad te responderemos en tu email " + correo + " , espera.";
mailMessage.IsBodyHtml = true;
try
{
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
smtpClient.Host = "smpt.live.com";
smtpClient.Port = 587;
smtpClient.Credentials = new System.Net.NetworkCredential("tucorreo@hotmail.com", "tuclave");
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
}
catch (Exception ex) {
Console.WriteLine("Ha ocurrido un error al enviar correo: {0}",ex.Message);
}
}
catch (Exception ex) {
Console.WriteLine("Ha ocurrido un error al adjuntar correo: {0}",ex.Message);
}
string nombreCompleto = nombre.ToUpper() +" " +apellidos.ToUpper();
ViewBag.TuNombre = nombreCompleto;
ViewBag.Respuesta = "Te responderemos en tu correo: " + correo;
return View("/Views/Formularios/ContactoRespuesta.cshtml");
}
Enviar correo con ASP .NET
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.