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.
80 lines
2.1 KiB
80 lines
2.1 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Net;
|
||
|
using System.Security.Cryptography.X509Certificates;
|
||
|
using System.Net.Security;
|
||
|
|
||
|
namespace QMFrameWork.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)
|
||
|
{
|
||
|
//没有传的邮件服务器信息为空时用系统默认的构造一个
|
||
|
if (ServerInfo == null)
|
||
|
{
|
||
|
ServerInfo = new SmtpServerInfo(SmtpServer, SenderUser, SenderPassword, DoMain, SenderUserEmail);
|
||
|
}
|
||
|
|
||
|
SmtpMailSender sender = new SmtpMailSender(ServerInfo, MailInfo);
|
||
|
sender.Send();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|