/// <summary>
/// 发送邮件 必须是企业邮箱
/// </summary>
/// <param name="ums"></param>
private void SendMail(UserMessage ums)
{
SysAdminManage sysadmin = new SysAdminManage();
DataSet dt = sysadmin.ShowSysAdminbyWhere("UserName = 'admin'");
if (dt.Tables.Count != 0)
{
string strTo = dt.Tables[0].Rows[0]["UserEmail"].ToString();
string strSubject = "养老预住信息";
MailMessage mm = new MailMessage();
mm.Priority = MailPriority.High;
mm.From = new MailAddress(strFrom, "养老预住信息", Encoding.GetEncoding(936));
mm.IsBodyHtml = true;
mm.Subject = strSubject;
mm.SubjectEncoding = Encoding.GetEncoding(936);
mm.Body = "姓名:" + ums.UserName + "<br/>身份证号码:" + ums.UserIDCard + "<br/>电话号码:" + ums.UserPhone + "<br/>所在地址:" + ums.UAddress + "<br/>住户邮箱:" + ums.UEmail;
mm.To.Add(strTo.Replace('|', '.'));
mm.BodyEncoding = Encoding.GetEncoding(936);
}
}
public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, MailMessage message)
{
try
{
SmtpClient client = new SmtpClient(strSmtpServer);
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(message);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}