Para enviar un correo electronico utilizo la siguiente funcion:
private bool sendMail(string From, string To, string Subject, string
Mensaje, string SmtpServer, string Attach)
{
try
{
MailMessage oMsg = new MailMessage();
oMsg.From = From;
oMsg.To = To;
oMsg.Subject = Subject;
// SEND IN HTML FORMAT (comment this line to send plain text).
oMsg.BodyFormat = MailFormat.Html;
//oMsg.BodyFormat = MailFormat.Text;
oMsg.Body = Mensaje;
if (Attach !=null)
{
MailAttachment myAttachment = new
MailAttachment(Attach);
oMsg.Attachments.Add(myAttachment);
}
// TODO: Replace with the name of your remote SMTP server.
SmtpMail.SmtpServer = SmtpServer;
SmtpMail.Send(oMsg);
oMsg = null;
Attach=null;
return true;
}
catch (Exception e)
{
//Console.WriteLine("{0} Exception caught.", e);
return false;
}
}
El problema es que cuando pongo como smtp (ej: mailhost.servidor.es) solo me
deja enviar mensajes a direcciones de correo X...@servidor.es. Si pongo un otra
dirección ej: p...@hotmail.com me da el siguiente error:
"Could not access 'CDO.Message' object."
para eso un susuario registrado en tu servicio de correo debe
authentificarse, puedes usar
oMsg..Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
oMsg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] =
"myusername";
oMsg.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] =
"mypass";
Saludos
Emir Treviño
MEXICO
"Emir Treviño" <emir.t...@gmail.com> escribió en el mensaje
news:BE6DCFA5-C655-48C4...@microsoft.com...
* Seguramente lo usarán muchos como tu, sobre todo para enviar spamm
* Por su uso ilimitado, se saturara y aveces tus correos no podrán enviarse
* será más lento de lo normal
* Fomentas el uso de servidores inseguros y el spamm
Si en realidad deseas NO USAR authenticación te recomiendo que uses un
servidor interno, por ejemplo el servicio SMTP del IIS, y que bloquees el
puerto 25 al exterior.
Saludos
Emir Treviño
MEXICO