Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void EnviarCorreo(string CorreoProveedor, string CorreoPersona, string Asunto,
- string contenido, ref string output)
- {
- if (CorreoPersona != "")
- {
- MailMessage mensaje = new MailMessage();
- mensaje.From = new MailAddress("nocontestar@metalcast.com.mx");
- mensaje.To.Add(new MailAddress(CorreoPersona)); //aqui he intentado con cuentas de
- //@metalcast.com.mx y tambien con cuentas gmail pero ambas
- //dan el mismo error o tambien me marca
- //"No se puede escribir datos
- //de en la conexión de transporte: net_io_connectionclosed"
- mensaje.Subject = Asunto;//el valor que pongo es "Asunto"
- mensaje.Body = contenido;//aqui puse "contenido"
- mensaje.IsBodyHtml = false;
- mensaje.Priority = MailPriority.Normal;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "metalcast.com.mx";
- smtp.Port = 25;
- smtp.EnableSsl = false;
- smtp.UseDefaultCredentials = false;
- smtp.Timeout = 10000;
- smtp.Credentials = new NetworkCredential("nocontestar@metalcast.com.mx", "psw");
- try
- {
- smtp.Send(mensaje);
- mensaje.Dispose();
- output = "Se ha enviado un correo exitosamente";
- }
- catch (Exception es)
- {
- mensaje.Dispose();
- output = es.Message;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement