Hola, tengo un pequeño problema para enviar email desde mi ordenador,
tengo este codigo para enviar email:
try
{
MailMessage oMsg = new MailMessage();
oMsg.From = new MailAddress("
[email protected]");
// TODO: Replace with recipient e-mail address.
oMsg.To.Add("
[email protected]");
oMsg.Subject = "E-mail de prueba";
// SEND IN HTML FORMAT (comment this line to send plain text).
oMsg.IsBodyHtml = true;
// HTML Body (remove HTML tags for plain text).
oMsg.Body = "<HTML><BODY><B>Se envia bien</B></BODY></HTML>";
// ADD AN ATTACHMENT.
// TODO: Replace with path to attachment.
String sFile = @"C:\ruta\correspondencia.doc";
Attachment oAttch = new Attachment(sFile);
oMsg.Attachments.Add(oAttch);
// TODO: Replace with the name of your remote SMTP server.
SmtpClient cliente = new SmtpClient();
cliente.Host = "smtp.gmail.com";
cliente.Credentials = new System.Net.NetworkCredential("
[email protected]", "micontraseña");
cliente.Send(oMsg);
oMsg = null;
oAttch = null;
}
catch (Exception error)
{
MessageBox.Show(error.Message, "Error");
}
y siempre me da error, lo que me preocupa es que en mi maquina me da un error distinto a las demas maquinas, y me dice que ' No es posible conectar con el servidor remoto'.
supongo que sera un tema de permisos o de firewall o algo asi, pero no consigo arreglarlo...
¿Alguien me puede hechar una mano?