gpt4 book ai didi

c# - 在c#中发送邮件到gmail ssl问题

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

我尝试通过 C# 向我发送邮件,但每次都会出现 SSL 错误。你能告诉我哪里出了问题吗?

谢谢

SmtpClient mail = new SmtpClient();
MailMessage msg = new MailMessage("address", "address");
msg.Subject = "send data";
msg.Body = "Stuff";
mail.Credentials = new NetworkCredential("username", "pw");
mail.Host = "smtp.googlemail.com";

Attachment data = new Attachment(path1);
msg.Attachments.Add(data);
Attachment data2 = new Attachment(path2);
msg.Attachments.Add(data2);
Attachment data3 = new Attachment(path3);
msg.Attachments.Add(data3);

mail.Send(msg);

最佳答案

mail.DeliveryMethod = SmtpDeliveryMethod.Network;
mail.EnableSsl = true;
mail.Port = 587;

关于c# - 在c#中发送邮件到gmail ssl问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4285896/

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