使用Gmail SMTP发送邮件失败
问题描述:
我在这里发帖是因为我一直在尝试很多次通过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"
当你进入代码时,发生错误的确切位置是什么? – jamiedanq
你可以分享堆栈跟踪吗? – hardkoded
错误发生在: smpt.Send(msg); –