0

我得到」遠程名稱無法解析:'smtp.live.com'「異常不斷從過去2小時試圖發送簡單的郵件。 這裏是我的代碼:發送郵件失敗:{「遠程名稱無法解析:'smtp.live.com'}}

  MailMessage mailMessage = new MailMessage(); 
      mailMessage.From = new MailAddress("[email protected]", "Some Name"); 
      mailMessage.To.Add(new MailAddress("[email protected]")); 
      mailMessage.IsBodyHtml = true; 
      mailMessage.Body = "<b>This is a check email</b>"; 
      mailMessage.Subject = "Test subject"; 

      SmtpClient smtpClient = new SmtpClient(); 
      smtpClient.Port = 587; //also tried 25 and 465 
      smtpClient.Host = "smtp.live.com"; //also tried smtp-mail.outlook.com 
      smtpClient.EnableSsl = true; 
      smtpClient.UseDefaultCredentials = false; //also tried removing the credentials and setting this to true 
      smtpClient.Credentials = new NetworkCredential("[email protected]", "its password"); 

      smtpClient.Send(mailMessage); 

      Console.WriteLine("Success"); 

只是出於好奇,我曾嘗試加入smtp.gmail.com到主機並輸入我的Gmail憑證爲好,但也不能工作。這裏的痕跡:

System.Net.Mail.SmtpException was caught 
    Message=Failure sending mail. 
    Source=System 
    StackTrace: 
     at System.Net.Mail.SmtpClient.Send(MailMessage message) 
     at ConsoleApplication1.Program.Main(String[] args) in C:\Users\italha\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs:line 95 
    InnerException: System.Net.WebException 
     Message=The remote name could not be resolved: 'smtp.live.com' 
     Source=System 
     StackTrace: 
      at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) 
      at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) 
      at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) 
      at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) 
      at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) 
      at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) 
      at System.Net.Mail.SmtpClient.GetConnection() 
      at System.Net.Mail.SmtpClient.Send(MailMessage message) 
     InnerException: 

這裏是NSLOOKUP顯示我要smtp.live.com: enter image description here

我的Internet連接使用代理地址和端口8080,是什麼問題?請爲我的具體問題提供解決方案,我已經嘗試了所有可用的互聯網通用解決方案。

+1

您是否也使用smtp代理? –

+1

您的郵件憑據是否有效? –

+0

好吧,它甚至沒有嘗試建立連接,但它沒有解決IP - 所以顯然它花了太長的時間來解決..如果你有一個http代理,你可能/幾乎肯定會遇到防火牆問題,機會端口是不是打開你的機器直接通話 – BugFinder

回答

0

看起來您的網絡設置存在問題,或者防火牆阻止了郵件服務器。代碼看起來很好。

嘗試用跟蹤ping主機名並查看是否有效

+0

是的,我向我的網絡管理員詢問了這個問題,他向我保證,其他smtp不能從我們的網絡訪問。他們被阻止 –

+0

請將此標記爲答案,以便這可能有助於任何未來有同樣問題的人。謝謝 –

-3

正確檢查互聯網連接,然後重試。 這對我有效。

+0

問題中的詳細信息表明這不是互聯網連接問題 – EvilGeniusJamie

相關問題