Possible Duplicate:
Sending email in .NET through Gmail發送電子郵件使用Gmail SMTP C#
你好,
進出口使用的代碼像下面,但我得到一個錯誤:
"Unable to connect to the remote server"
MailMessage mail = new MailMessage();
mail.To.Add("[email protected]");
mail.From = new MailAddress("[email protected]");
mail.Subject = "Test Email";
string Body = "<b>Welcome to CodeDigest.Com!!</b>";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "myPass");
smtp.EnableSsl = true;
smtp.Send(mail);
代碼看起來不錯。您的防火牆很可能阻止該端口上的傳出請求。 – 2011-05-04 13:45:04
嘗試使用端口號465進行SSL連接。 – Joe 2014-01-02 13:24:50