-1
這些代碼有什麼問題?所有時間都會拋出異常「{」發送郵件失敗。「}」!我不知道爲什麼。請幫幫我。SMTP Live.com「發送郵件失敗」
編輯:內部異常:{ 「無法連接到遠程服務器」}使用關鍵字
string smtpAddress = "smtp.live.com";
int portNumber = 587;
bool enableSSL = true;
string emailFrom = "[email protected]";
string password = "myPassword";
string emailTo = "[email protected]";
string subject = "Hello";
string body = "Hello, I'm just writing this to say Hi!";
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress(emailFrom);
mail.To.Add(emailTo);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = false;
using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
{
smtp.Credentials = new NetworkCredential(emailFrom, password);
smtp.EnableSsl = enableSSL;
smtp.Send(mail);
}
}
檢查是否有內部異常更多信息 – Zakos 2014-09-02 08:12:56
內部異常:{「無法連接到遠程服務器」} 上網工程。 – Peiper 2014-09-02 08:13:49
{「連接嘗試失敗,因爲連接方在一段時間後沒有正確響應,或建立的連接失敗,因爲連接的主機未能響應myIPAdresse」} – Peiper 2014-09-02 08:15:53