/// <summary> /// 发送邮件 /// </summary> /// <param name="title">邮件标题</param> /// <param name="content">邮件内容</param> /// <param name="receiveEmail">收件人</param> public void SendEmail(string title, string content, string receiveEmail) { string eMailUserName = "aaaaaa"; //要显示的发件人名称 string eMailPassWord = "bbbbbb"; //发件用户的邮箱密码 string eMailHost = "smtp.gmail.com"; //发件邮箱所在的邮件发件服务器 int eMailPort = 587; //邮件发送端口 bool eMailEnableSSL = true; //是否启用发件安全协议 string eMailFromAddress = ""; //发件人邮箱账号 System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); smtp.Credentials = new System.Net.NetworkCredential(eMailUserName, eMailPassWord); smtp.Host = eMailHost; smtp.Port = eMailPort; smtp.EnableSsl = eMailEnableSSL; System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); mail.Subject = title; //主题 mail.Body = content; //正文 mail.From = new System.Net.Mail.MailAddress(eMailFromAddress); //发件人 mail.SubjectEncoding = System.Text.UTF8Encoding.UTF8; //发送邮件主题内容编码 mail.BodyEncoding = System.Text.UTF8Encoding.UTF8; //发送邮件内容编码 mail.Priority = System.Net.Mail.MailPriority.High; //优先级别 mail.IsBodyHtml = true; //邮件内容是否以HTML格式嵌套在邮件中 mail.To.Add(receiveEmail); //添加邮件收件人 smtp.Send(mail); //发送 }