本文发表在 rolia.net 枫下论坛C# 2008 (From is my gmail account; Password is my gmail password)
..
// Send out emails
MailMessage message = new MailMessage();
message.From = new MailAddress(From.ToString());
message.To.Add(new MailAddress(To.ToString()));
message.Subject = Subject.ToString();
message.IsBodyHtml = true ;
message.Body = Body.ToString();
SmtpClient client = new SmtpClient();
client.EnableSsl = true; //also works for TLS protocol
client.Host = "smtp.gmail.com";
client.Port = 587;
client.Credentials = new NetworkCredential(From, Password);
try
{
client.Send(message);
return "";
}
catch (Exception exc)
{
return exc.ToString();
}
...
error message: can't connect remote server; target machine actually refuse....
any idea about that? Weird. this code was working almost 1 year.
Thanks更多精彩文章及讨论,请光临枫下论坛 rolia.net
..
// Send out emails
MailMessage message = new MailMessage();
message.From = new MailAddress(From.ToString());
message.To.Add(new MailAddress(To.ToString()));
message.Subject = Subject.ToString();
message.IsBodyHtml = true ;
message.Body = Body.ToString();
SmtpClient client = new SmtpClient();
client.EnableSsl = true; //also works for TLS protocol
client.Host = "smtp.gmail.com";
client.Port = 587;
client.Credentials = new NetworkCredential(From, Password);
try
{
client.Send(message);
return "";
}
catch (Exception exc)
{
return exc.ToString();
}
...
error message: can't connect remote server; target machine actually refuse....
any idea about that? Weird. this code was working almost 1 year.
Thanks更多精彩文章及讨论,请光临枫下论坛 rolia.net