转自:https://www.cnblogs.com/GoCircle/p/6117038.html
1 public static void Send () 2 { 3 MailMessage msg = new MailMessage(); 4 5 msg.To.Add("收件人地址@qq.com"); 6 msg.CC.Add("抄送人地址@qq.com"); 7 8 msg.From = new MailAddress("发件人邮箱@qq.com", "名称"); 9 10 msg.Subject = "邮件标题"; 11 //标题格式为UTF8 12 msg.SubjectEncoding = Encoding.UTF8; 13 14 msg.Body = "邮件内容"; 15 //内容格式为UTF8 16 msg.BodyEncoding = Encoding.UTF8; 17 18 SmtpClient client = new SmtpClient(); 19 //SMTP服务器地址 20 client.Host = "smtp.qq.com"; 21 //SMTP端口,QQ邮箱填写587 22 client.Port = 587; 23 //启用SSL加密 24 client.EnableSsl = true; 25 26 client.Credentials = new NetworkCredential("发件人邮箱账号@qq.com", "密码或者授权码"); 27 //发送邮件 28 client.Send(msg);
msg.Dispose();
client.Dispose(); 29 }