天津投入产出系统后端
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.
 
 
 
 
 
 

71 lines
1.9 KiB

using System;
namespace QM.Exchange.Adapters.Mail
{
/// <summary>
/// 邮件发送接口
/// </summary>
public class MailHelper
{
#region 属性
/// <summary>
/// 邮件服务器地址
/// </summary>
public static string SmtpServer { set; get; }
/// <summary>
/// 发送人用户
/// </summary>
public static string SenderUser { set; get; }
/// <summary>
/// 发送人密码
/// </summary>
public static string SenderPassword { set; get; }
/// <summary>
/// 邮件服务器
/// </summary>
public static string DoMain { set; get; }
/// <summary>
/// 发件人邮箱
/// </summary>
public static string SenderUserEmail { set; get; }
#endregion
#region 标准邮件发送接口
/// <summary>
/// 发送邮件
/// </summary>
public void SendMailForServer(MailInfo MailInfo, SmtpServerInfo ServerInfo)
{
//没有传的邮件服务器信息为空时用系统默认的构造一个
if (ServerInfo == null)
{
ServerInfo = new SmtpServerInfo(SmtpServer, SenderUser, SenderPassword, DoMain, SenderUserEmail);
}
SmtpMailSender sender = new SmtpMailSender(ServerInfo, MailInfo);
sender.Send();
}
/// <summary>
/// 发送邮件
/// </summary>
public void SendMail(MailInfo MailInfo)
{
//没有传的邮件服务器信息为空时用系统默认的构造一个
SmtpServerInfo ServerInfo = new SmtpServerInfo(SmtpServer, SenderUser, SenderPassword, DoMain, SenderUserEmail);
SmtpMailSender sender = new SmtpMailSender(ServerInfo, MailInfo);
sender.Send();
}
#endregion
}
}