1 public void SendMail() 2 { 3 MailMessage mail = new MailMessage(); 4 mail.From = new MailAddress("fromMail", "fromDisplayName", System.Text.Encoding.UTF8); 5 //添加收件人 6 mail.To.Add(""); 7 // 添加抄送 8 mail.CC.Add(""); 9 // 添加密送 10 mail.Bcc.Add(""); 11 // 主题 12 mail.SubjectEncoding = System.Text.Encoding.UTF8; 13 mail.Subject = ""; 14 // 内容 15 mail.IsBodyHtml = true; 16 mail.BodyEncoding = System.Text.Encoding.UTF8; 17 mail.Body = ""; 18 19 SmtpClient smtp = new SmtpClient("smtp host"); 20 smtp.Credentials = new NetworkCredential("fromMail", "pwd"); 21 smtp.Send(mail); 22 }
时间: 2024-10-25 22:28:39