日期:2011-06-22 浏览次数:20453 次
//============================================================
// File: MailSender.cs
// 邮件发送组件
// 支持ESMTP, 多附件
//============================================================
namespace JcPersonal.Utility
{
using System;
using System.Collections;
using System.Net.Sockets;
using System.IO;
using System.Text;
/// <summary>
/// Mail 发送器
/// </summary>
public class MailSender
{
/// <summary>
/// SMTP服务器域名
/// </summary>
public string Server {
get { return server; }
set { if (value != server) server = value; }
} private string server = "";
/// <summary>
/// SMTP服务器端口 [默认为25]
/// </summary>
public int Port {
get { return port; }
set { if (value != port) port = value; }
} private int port = 25;
/// <summary>
/// 用户名 [如果需要身份验证的话]
/// </summary>
public string UserName {
get { return userName; }
set { if (value != userName) userName = value; }
} private string userName = "";
/// <summary>
/// 密码 [如果需要身份验证的话]
/// </summary>
public string Password {
get { return password; }
set { if (value != password) password = value; }
} private string password = "";
/// <summary>
/// 发件人地址
/// </summary>
public string From {
get { return from; }
set { if (value != from) from = value;}
} private string from = "";
/// <summary>
/// 收件人地址
/// </summary>
public string To {
get { return to; }
set { if (value != to) to = value;}
} private string to = "";
/// <summary>
/// 发件人姓名
/// </summary>
public string FromName {
get { return fromName; }
set { if (value != fromName) fromName = value; }
} private string fromName = "";
/// <summary>
/// 收件人姓名
/// </summary>
public string ToName {
get { return toName; }
set { if (value != toName) toName = value; }
} private string toName = "";
/// <summary>
/// 邮件的主题
/// </summary>
public string Subject {
get { return subject; }
set { if (value != subject) subject = value; }
} private string subject = "";
/// <summary>
/// 邮件正文
/// </summary>
public string Body {
get { return body; }
set { if (value != body) body = value; }
} private string body = "";
/// <summary>
/// 超文本格式的邮件正文
/// </summary>
public string HtmlBody {
get { return htmlBody; }
set { if (value != htmlBody) htmlBody = value; }
} private string htmlBody = "";
/// <summary>
/// 是否是html格式的邮件
/// </summary>
public bool IsHtml {
get { return isHtml; }
set { if (value != isHtml) isHtml = value; }
} private bool isHtml = false;
/// <summary>
/// 语言编码 [默认为G