protected void BtnSubmit_Click(object sender, EventArgs e)
{
GetAllUsersName U = new GetAllUsersName();
string Email = U.GetUSEREmail(TxtEmailPass.Text);
SmtpClient mySmtpClient = new SmtpClient("smtp.gmail.com", 587);
mySmtpClient.EnableSsl = true;
mySmtpClient.UseDefaultCredentials = false;
mySmtpClient.Credentials = new NetworkCredential("Projects@gmail.com", "Pro123456789");
mySmtpClient.EnableSsl = true;
MailMessage msg = new MailMessage("Projects@gmail.com", Email, "Password", "your password is:");
mySmtpClient.Send(msg);
}
这是我的代码,但它一直告诉我:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
最佳答案
您的代码看起来不错。如果这是一个新帐户,请确保更改密码 - 至少一次。 Gmail 可能正在找您更改密码。
关于c# - 如何从 C# 向 Gmail 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30440158/