我有这个代码发送电子邮件但是有一个错误....我在谷歌搜索,我看到大多数使用的代码都类似于我...
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
message.From = new MailAddress(test.host.com);
message.To.Add(new MailAddress(test@gmail.com));
//not the actual email just a dummy value
message.Subject = "Sending mail";
message.Body = "testing";
smtp.Port = 465;
smtp.Timeout = 30 * 1000,
smtp.Host = "host.com.sg";
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("username", "password");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
MessageBox.Show("Message has been sent");
我收到的新错误是发送邮件失败
答案 0 :(得分:0)
也许您需要为不可靠的应用程序授予帐户访问权限。 请查看:https://www.google.com/settings/security/lesssecureapps