2017-05-30 165 views
-2

我在這裏發帖是因爲我一直在嘗試很多次通過c#(Visual Studio 2015)中的程序發送電子郵件,但我不能。唯一的例外是:使用Gmail SMTP發送郵件失敗

型「System.Net.Mail.SmtpException」未處理的異常發生在System.dll中 其他信息:發送郵件失敗。

而且我的代碼如下:

MailMessage msg = new MailMessage(from.Text, to.Text, subject.Text, body.Text); 
SmtpClient smclient = new SmtpClient("smpt.gmail.com", 587); //465 
smclient.Credentials = new System.Net.NetworkCredential("[email protected]", "(password)"); 
smclient.EnableSsl = true; 
smclient.Send(msg); 
MessageBox.Show("Mail Sent"); 

其中:

from.text = "[email protected]" 
to.text = "[email protected]" 
subject.text = "Sending email" 
body.text = "hello world, how are you" 
+0

當你進入代碼時,發生錯誤的確切位置是什麼? – jamiedanq

+0

你可以分享堆棧跟蹤嗎? – hardkoded

+0

錯誤發生在: smpt.Send(msg); –

回答