用c#写的smtp邮件发送类__教程 |
|
日期:2007-5-20 1:21:25 人气:114 [大 中 小] |
|
|
|
private TcpClient tc; /// <summary> /// 网络流 /// </summary> private NetworkStream ns; /// <summary> /// 错误的代码字典 /// </summary> private StringDictionary errorCodes=new StringDictionary(); /// <summary> /// 操作执行成功后的响应代码字典 /// </summary> private StringDictionary rightCodes=new StringDictionary(); /// <summary> /// 执行过程中错误的消息 /// </summary> private string errorMessage=""; /// <summary> /// 记录操作日志 /// </summary> private string logs=""; /// <summary> /// 主机登陆的验证方式 /// </summary> private StringCollection validateTypes=new StringCollection(); /// <summary> /// 换行常数 /// </summary> private const string CRLF="\r\n"; private string serverName="smtp"; private string logPath=null; private string userid=null; private string password=null; private string mailEncodingName="GB2312"; private bool sendIsComplete=false; private SmtpValidateTypes smtpValidateType=SmtpValidateTypes.Login; #endregion #region "propertys" /// <summary> /// 获取最后一此程序执行中的错误消息 /// </summary> public string ErrorMessage { get{return this.errorMessage;} } /// <summary> /// 获取或设置日志输出路径 /// </summary> public string LogPath { get { return this.logPath; } set{this.logPath=value;} } /// <summary> /// 获取或设置登陆smtp服务器的帐号 /// </summary> public string UserID { get{return this.userid;} set{this.userid=value;} } /// <summary> /// 获取或设置登陆smtp服务器的密码 /// </summary> public string Password { get{return this.password;} set{this.password=value;} } /// <summary> /// 获取或设置要使用登陆Smtp服务器的验证方式 /// </summary> public SmtpValidateTypes SmtpValidateType { get{return this.smtpValidateType;} set{this.smtpValidateType=value;} } #endregion #region "construct functions" /// <summary> /// 构造函数 /// </summary> /// <param name="server">主机名</param> /// <param name="port">端口</param> public KSN_Smtp(string server,int port) { tc=new TcpClient(server,port); ns=tc.GetStream(); this.serverName=server; this.initialFields(); } /// <summary> /// 构造函数 /// </summary> /// <param name="ip">主机ip</param> /// <param name="port">端口</param> public KSN_Smtp(IPAddress ip,int port) { IPEndPoint endPoint=new IPEndPoint(ip,port); tc=new TcpClient(endPoint); ns=tc.GetStream(); this.serverName=ip.ToString(); this.initialFields(); } #endregion #region "methods" private void initialFields() //初始化连接 { logs="================"+DateTime.Now.ToLongDateString()+" "+DateTime.Now.ToLongTimeString()+"==============="+CRLF; |
|
出处:本站原创 作者:佚名 |
|
|