c# - SMTP 服务器需要安全连接。- 控制台应用程序
问题描述
当我打开我的控制台应用程序项目时,它说:
这是我的代码:
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("your mail@gmail.com");
mail.To.Add("to_mail@gmail.com");
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("c:\text.txt");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("save111sender@gmail.com", "test123test.");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
请帮我解决这个问题。
解决方案
推荐阅读
- docker - 启用用户命名空间重新映射后,docker 容器中的进程会剥夺哪些权限?
- java - 从 Java 到 Swift 的 CustomComparator
- c++ - 如何编写 Axie 服务器的最小 GraphQL 查询?
- r - 解析url并在粘贴url时获取相同的url
- reactjs - 在反应中用 t.PartialC<{}> 定义的类型上不存在属性“属性”
- reactjs - 为什么我需要在 onChange 事件的处理程序的 return 语句中传递一个函数
- java - 使用循环重置基本财务计算器
- javascript - Javascript 查找以太坊钱包
- google-cloud-platform - CPU 限制未更新
- ios - 尝试在 SwiftUI 应用程序中使列表保持最新