diff --git a/北京北汽/SCP/Common/MailHelper.cs b/北京北汽/SCP/Common/MailHelper.cs index e26c431..ca959da 100644 --- a/北京北汽/SCP/Common/MailHelper.cs +++ b/北京北汽/SCP/Common/MailHelper.cs @@ -9,6 +9,7 @@ using CK.SCP.Models.AppBoxEntity; using System.Text; using CK.SCP.Utils; using System.Configuration; +using MailKit.Security; namespace SCP.Common { @@ -46,8 +47,9 @@ namespace SCP.Common mailbody += "你好!

"; mailbody += "" + p_Content + " ,请到供应商协同网站" + ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看!
"; mailbody += "



日期:" + DateTime.Now; - MyWebSmtpMail webmail = new MyWebSmtpMail(); - webmail.Send(mails, mailbody, p_title); + //MyWebSmtpMail webmail = new MyWebSmtpMail(); + SendMailOptimization(mails, mailbody, p_title); + //webmail.Send(mails, mailbody, p_title); } } } @@ -145,6 +147,34 @@ namespace SCP.Common } } - + + + /// + /// 优化发邮件 + /// + /// + /// + /// + public static void SendMailOptimization(string mails = "", string mailbody = "", string p_MailTitle = "") + { + try + { + List toList = new List(); + EmailAddress add = new EmailAddress(mails, mails); + toList.Add(add); + var smtpMailSender = new MailKitMailSender(SecureSocketOptions.StartTls); + smtpMailSender.BuildMessage( + toList, + p_MailTitle, + mailbody, + "BBC" + ); + smtpMailSender.Send(); + } + catch (Exception e) + { + LogHelper.Writlog(LogHelper.LogType.Error, typeof(MailManager), "MailManager", e.Message + e.InnerException?.Message); + } + } } } \ No newline at end of file