Consider the following written in .NET Core 2.0.
SmtpClient client = new SmtpClient("smtp.exmail.qq.com", )
{
UseDefaultCredentials = true,
Credentials = new NetworkCredential("test@kzwr.com", "yHbgby"),
EnableSsl = true
}; MailMessage mailMessage = new MailMessage("test@kzwr.com", "10001@qq.com")
{
Body = "<h1>body</h1>",
Subject = "subject",
BodyEncoding = Encoding.UTF8,
IsBodyHtml = true
}; client.Send(mailMessage); client.Dispose();
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!