gpt4 book ai didi

c# - 如何从 C# 向 Gmail 发送电子邮件

转载 作者:太空宇宙 更新时间:2023-11-03 13:07:00 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com