特点:
1. 支持SMTP验证
2. 支持群发功能
3. 支持各种免费邮箱,如sohu,163等
4. 支持Win2k Server自带的smtp服务器,即只要你联网,配置好smtp服务器,即可本机发邮件
5. 完整的错误代码,拥有Logs和HTMLlogs两个日志功能,可以输出详细的服务器--客户端交互日志
代码如下:
----------------------------------------------
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Collections;
namespace Sanxing.Mail.Data
{
public class ESmtpMail
{
//内部变量
/// <summary>
/// 设置换行变量
/// </summary>
private string enter="\r\n";
/// <summary>
/// 设定语言代码,默认设定为GB2312,如不需要可设置为""
/// </summary>
private string Charset="GB2312";
/// <summary>
/// 发件人地址
/// </summary>
private string From="";
/// <summary>
/// 发件人姓名
/// </summary>
private string FromName="";
/// <summary>
/// 回复邮件地址
/// </summary>
//public string ReplyTo="";
/// <summary>
/// 收件人姓名
/// </summary>
private 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>
private bool HTML=false;
/// <summary>
/// 邮件附件列表
/// </summary>
private System.Collections.ArrayList Attachments;
/// <summary>
/// 邮件发送优先级,可设置为"High","Normal","Low"或"1","3","5"
/// </summary>
private string priority="Normal";
/// <summary>
/// 邮件主题
/// </summary>
private string Subject="";
/// <summary>
/// 邮件正文
/// </summary>
private 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