gpt4 book ai didi

c# - 系统.Security.Cryptography.CryptographicException : The handle is invalid

转载 作者:太空狗 更新时间:2023-10-29 21:58:48 36 4
gpt4 key购买 nike

我在通过 C# 发送邮件时遇到异常

SmtpClient client = new SmtpClient() 

作为 System.Security.Cryptography.CryptographicException:句柄无效。

MailMessage mail = new MailMessage(from,to);

mail.To.Add(to);
mail.From = new MailAddress(from, "", System.Text.Encoding.UTF8);

mail.Subject = "This is a test mail";

mail.SubjectEncoding = System.Text.Encoding.UTF8;

mail.Body = fr.message;

mail.BodyEncoding = System.Text.Encoding.UTF8;

mail.IsBodyHtml = true;

mail.Priority = MailPriority.High;

SmtpClient client = new SmtpClient();

//Add the Creddentials- use your own email id and password
client.Credentials = new System.Net.NetworkCredential(from, Password);

client.Port = 587; // Gmail works on this port

client.Host = "smtp.gmail.com";

client.EnableSsl = true; //Gmail works on Server Secured Layer

client.Send(mail);

我不明白为什么会这样?

最佳答案

检查您的项目设置并确保您已选中 NTLM 身份验证:

enter image description here

关于c# - 系统.Security.Cryptography.CryptographicException : The handle is invalid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11932116/

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