You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
using CK.SCP.Utils;
|
|
using MailKit.Security;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CK.SCP.Common
|
|
{
|
|
public class MailManager
|
|
{
|
|
/// <summary>
|
|
/// 发送邮件
|
|
/// </summary>
|
|
/// <param name="mails"></param>
|
|
/// <param name="mailbody"></param>
|
|
/// <param name="p_MailTitle"></param>
|
|
public static void SendMailOrders(string mails = "", string mailbody = "", string p_MailTitle = "")
|
|
{
|
|
try
|
|
{
|
|
List<EmailAddress> toList = new List<EmailAddress>();
|
|
EmailAddress add = new EmailAddress(mails, mails);
|
|
toList.Add(add);
|
|
var smtpMailSender = new MailKitMailSender(SecureSocketOptions.StartTls);
|
|
smtpMailSender.BuildOrderMessage(
|
|
toList,
|
|
p_MailTitle,
|
|
mailbody,
|
|
"BBC"
|
|
);
|
|
smtpMailSender.SendOrder();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(MailManager), "MailManager", e.Message + e.InnerException?.Message);
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|