日期:2013-04-29  浏览次数:20543 次

using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Collections;

namespace lion_office.Data.Library.MailClass
{
/*
Create By lion
2002-11-20 01:44
Copyright (C) 2001,2002 www.LionSky.Net. All rights reserved.
Web: http://www.Lionsky.net
Email: lion-a@sohu.com
Support .Net Framework Beta 2
*/
public class ESmtpMail
{
private string enter="\r\n";
/// <summary>
/// 设定语言代码,默认设定为GB2312,如不需要可设置为""
/// </summary>
public string Charset="GB2312";
/// <summary>
/// 发件人地址
/// </summary>
public string From="";
/// <summary>
/// 发件人姓名
/// </summary>
public string FromName="";
/// <summary>
/// 回复邮件地址
/// </summary>
//public string ReplyTo="";
/// <summary>
/// 收件人姓名
/// </summary>
public string RecipientName="";
/// <summary>
/// 收件人列表
/// </summary>
private Hashtable Recipient=new Hashtable();
/// <summary>
/// 邮件服务器域名
/// </summary>
private string mailserver="";
/// <summary>
/// 邮件服务器端口号
/// </summary>
private int mailserverport=25;
/// <summary>
/// SMTP认证时使用的用户名
/// </summary>
private string username="";
/// <summary>
/// SMTP认证时使用的密码
/// </summary>
private string password="";
/// <summary>
/// 是否需要SMTP验证
/// </summary>
private bool ESmtp=false;
/// <summary>
/// 是否Html邮件
/// </summary>
public bool Html=false;
/// <summary>
/// 邮件附件列表
/// </summary>
private System.Collections.ArrayList Attachments;
/// <summary>
/// 邮件发送优先级,可设置为"High","Normal","Low"或"1","3","5"
/// </summary>
private string priority="Normal";
/// <summary>
/// 邮件主题
/// </summary>
public string Subject="";
/// <summary>
/// 邮件正文
/// </summary>
public string Body="";
/// <summary>
/// 收件人数量
/// </summary>
private int RecipientNum=0;
/// <summary>
/// 最多收件人数量
/// </summary>
private int recipientmaxnum=1;
/// <summary>
/// 密件收件人数量
/// </summary>
//private int RecipientBCCNum=0;
/// <summary>
/// 错误消息反馈
/// </summary>
private string errmsg;
/// <summary>
/// TcpClient对象,用于连接服务器
/// </summary>
private TcpClient tc;
/// <summary>
/// NetworkStream对象
/// </summary>
private NetworkStream ns;
/// <summary>
/// SMTP错误代码哈希表
/// </summary>
private Hashtable ErrCodeHT = new Hashtable();
/// <summary>
/// SMTP正确代码哈希表
/// </summary>
private Hashtable RightCodeHT = new Hashtable();
public ESmtpMail()
{
Attachments = new System.