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!