using (var smtp = new SmtpClient())
using (var mail = new MailMessage(fromEmail, toEmail))
{
//图像附件
//ZIP附件
//var attach = new Attachment(Server.MapPath("报名表2014.doc"), "application/x-zip-compressed");
//mail.Attachments.Add(attach);
//标题和内容,注意设置编码,因为默认编码是ASCII
mail.Subject = "你好";
mail.SubjectEncoding = Encoding.UTF8;
//HTML内容
mail.Body = "<img src=\"cid:pic\"/><p>恭喜您注册成功</p>";
mail.BodyEncoding = Encoding.UTF8;
//指示改电子邮件内容是HTML格式
mail.IsBodyHtml = true;
//SMTP设置(根据邮箱类型设置,这里是Live Mail的SMTP服务器地址)
smtp.Host = "smtp.exmail.qq.com";
smtp.UseDefaultCredentials = false;
//某些SMTP服务器可能不支持SSL,会抛出异常
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential(fromEmail, fromPwd);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
//发送
smtp.Send(mail);