![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
public static void SendHMail(MailAddress mailTo, string mailSubject, string mailBody, MailAddress cc = null) { string MAIL_FROM = "test@test.com"; string body = System.DateTime.Now.ToString() + "<br/>"; body += mailBody + "<br/><br/><div style=\"font-size: 25px; font-weight: bold;\">Regards<br/>" + MAIL_FROM + "</div>"; MailMessage mail = new MailMessage { From = new MailAddress(MAIL_FROM), Subject = mailSubject, Body = body, BodyEncoding = Encoding.UTF8, IsBodyHtml = true }; mail.Headers.Add("Disposition-Notification-To", "<receipt@xxx.com>");//接收回执信息的邮箱地址 mail.To.Add(mailTo); if (cc != null) { mail.CC.Add(cc); } SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = "100.168.168.168"; smtpClient.Port = Convert.ToInt32(25); smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.Credentials = new NetworkCredential("userName", "passWord"); smtpClient.Send(mail); }
需要引用System.Net.Mail.其中
mail.Headers.Add("Disposition-Notification-To", "<receipt@xxx.com>");
实现了请求回执功能,第二个参数是接收回执的邮箱。
HMail邮件服务器搭建没什么好说的,执行安装程序,一直下一步就可以完成安装。
安装完成以后,可以通过OutLook连接HMail.配置如下: