公布我調(diào)試好的.Net發(fā)郵件程序,C#源碼公布。首局部
發(fā)表時(shí)間:2024-06-20 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]特點(diǎn):1. 支持SMTP驗(yàn)證2. 支持群發(fā)功能3. 支持各種免費(fèi)郵箱,如sohu,163等4. 支持Win2k Server自帶的smtp服務(wù)器,即只要你聯(lián)網(wǎng),配置好smtp服務(wù)器,即可本機(jī)發(fā)郵件5. 完整的錯(cuò)誤代碼,擁有Logs和HTMLlogs兩個(gè)日志功能,可以輸出詳細(xì)的服務(wù)器--客戶端交互日...
特點(diǎn):
1. 支持SMTP驗(yàn)證
2. 支持群發(fā)功能
3. 支持各種免費(fèi)郵箱,如sohu,163等
4. 支持Win2k Server自帶的smtp服務(wù)器,即只要你聯(lián)網(wǎng),配置好smtp服務(wù)器,即可本機(jī)發(fā)郵件
5. 完整的錯(cuò)誤代碼,擁有Logs和HTMLlogs兩個(gè)日志功能,可以輸出詳細(xì)的服務(wù)器--客戶端交互日志
代碼如下:
----------------------------------------------
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
{
//內(nèi)部變量
/// <summary>
/// 設(shè)置換行變量
/// </summary>
private string enter="\r\n";
/// <summary>
/// 設(shè)定語(yǔ)言代碼,默認(rèn)設(shè)定為GB2312,如不需要可設(shè)置為""
/// </summary>
private string Charset="GB2312";
/// <summary>
/// 發(fā)件人地址
/// </summary>
private string From="";
/// <summary>
/// 發(fā)件人姓名
/// </summary>
private string FromName="";
/// <summary>
/// 回復(fù)郵件地址
/// </summary>
//public string ReplyTo="";
/// <summary>
/// 收件人姓名
/// </summary>
private string RecipientName="";
/// <summary>
/// 收件人列表
/// </summary>
private Hashtable Recipient=new Hashtable();
/// <summary>
/// 郵件服務(wù)器域名
/// </summary>
private string mailserver="";
/// <summary>
/// 郵件服務(wù)器端口號(hào)
/// </summary>
private int mailserverport=25;
/// <summary>
/// SMTP認(rèn)證時(shí)使用的用戶名
/// </summary>
private string username="";
/// <summary>
/// SMTP認(rèn)證時(shí)使用的密碼
/// </summary>
private string password="";
/// <summary>
/// 是否需要SMTP驗(yàn)證
/// </summary>
private bool ESmtp=false;
/// <summary>
/// 是否Html郵件
/// </summary>
private bool Html=false;
/// <summary>
/// 郵件附件列表
/// </summary>
private System.Collections.ArrayList Attachments;
/// <summary>
/// 郵件發(fā)送優(yōu)先級(jí),可設(shè)置為"High","Normal","Low"或"1","3","5"
/// </summary>
private string priority="Normal";
/// <summary>
/// 郵件主題
/// </summary>
private string Subject="";
/// <summary>
/// 郵件正文
/// </summary>
private string Body="";
/// <summary>
/// 收件人數(shù)量
/// </summary>
private int RecipientNum=0;
/// <summary>
/// 最多收件人數(shù)量
/// </summary>
private int recipientmaxnum=1;
/// <summary>
/// 密件收件人數(shù)量
/// </summary>
//private int RecipientBCCNum=0;
/// <summary>
/// 錯(cuò)誤消息反饋
/// </summary>
private string errmsg;
/// <summary>
/// TcpClient對(duì)象,用于連接服務(wù)器
/// </summary>
private TcpClient tc;
/// <summary>
/// NetworkStream對(duì)象
/// </summary>
private NetworkStream ns;
/// <summary>
/// SMTP錯(cuò)誤代碼哈希表
/// </summary>
private Hashtable ErrCodeHT = new Hashtable();
/// <summary>
/// SMTP正確代碼哈希表
/// </summary>
private Hashtable RightCodeHT = new Hashtable();
/// <summary>
/// 服務(wù)器交互記錄
/// </summary>
private string logs="";
///<summary>
///HTML格式的服務(wù)器交互記錄
///</summary>
private string htmllog="";
-------------------------------------
代碼第一部分完畢