由于core不带smpt

所以借助MimeKit

以163邮箱为例

  var message = new MimeMessage ();
message.From.Add (new MailboxAddress ("王大昭", "181115XXXX@163.com"));
            message.To.Add(new MailboxAddress("王昭", "928877345@qq.com"));
            message.To.Add(new MailboxAddress("杨西西", "820291314@qq.com"));
            message.Subject = "本周工作报告";

            TextPart body = new TextPart(TextFormat.Html)
            {
                Text = "发一下本周工作报表 "
            };

            using (SmtpClient client = new SmtpClient())
            {
                //Smtp服务器
                client.Connect("smtp.163.com", 25, false);
                //登录,发送
                //特别说明,对于服务器端的中文相应,Exception中有编码问题,显示乱码了
                client.Authenticate("注册的邮箱", "授权验证码");

                client.Send(message);
                //断开
                client.Disconnect(true);
                Console.WriteLine("发送邮件成功");
            }

相关文章:

  • 2022-02-26
  • 2021-06-18
  • 2022-03-09
  • 2021-11-15
  • 2021-07-13
猜你喜欢
  • 2021-04-06
  • 2021-12-14
  • 2021-11-23
  • 2022-12-23
  • 2021-07-04
  • 2021-05-27
相关资源
相似解决方案