Consider the following written in .NET Core 2.0.

 1             SmtpClient client = new SmtpClient("smtp.exmail.qq.com", 587)
 2             {
 3                 UseDefaultCredentials = true,
 4                 Credentials = new NetworkCredential("test@kzwr.com", "yHbgby"),
 5                 EnableSsl = true
 6             };
 7 
 8             MailMessage mailMessage = new MailMessage("test@kzwr.com", "10001@qq.com")
 9             {
10                 Body = "<h1>body</h1>",
11                 Subject = "subject",
12                 BodyEncoding = Encoding.UTF8,
13                 IsBodyHtml = true
14             };
15 
16             client.Send(mailMessage);
17 
18             client.Dispose();
19             mailMessage.Dispose(); 

 

 For the most part, if you had code that could send email via SMTP in the full framework, it’s likely a matter of a copy and paste job to get it going in .NET Core now!

相关文章:

  • 2021-09-12
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2021-09-22
相关资源
相似解决方案