2017-06-14 83 views
0

我一直在努力從幾個月,請有人幫我解決這個問題。由於無法通過IIS服務器發送電子郵件(在本地工作)

try 
     { 
      SmtpClient smtpServer = new SmtpClient(); 
      MailMessage mail = new MailMessage(); 
      smtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "throughput"); 
      smtpServer.Port = 25; 
      smtpServer.Host = "*****"; 
      smtpServer.EnableSsl = true; 
      smtpServer.UseDefaultCredentials = true; 
      mail.From = new MailAddress("*****@outlook.com", "Work Order System"); 
      mail.To.Add("*******@outlook.com"); 
      // mail.To.Add(receiptsArray.ToString()); 
      mail.Subject = "Test"; 
      mail.Body = "Hello"; 
      smtpServer.Send(mail); 
     } 

回答

0

測試該代碼:

 MailMessage mail = new MailMessage(); 
     SmtpClient SmtpServer = new SmtpClient("smtp.live.com"); 

     mail.From = new MailAddress("[email protected]"); 
     mail.To.Add("[email protected]"); 

     mail.Subject = "Mail Subject"; 
     mail.Body = "Mail Body"; 

     SmtpServer.Port = 587; 
     SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "Write Your Password"); 

     SmtpServer.EnableSsl = true; 
     SmtpServer.Send(mail); 
+0

謝謝,我嘗試過了,它甚至沒有在本地主機的工作。只有Outlook.MailItem oMsg =(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem); –

+0

正在本地主機中發送電子郵件。 –

相關問題