当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>C++进阶与实例

发布源码:用Socket编写高效的Esmtp

    using System;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using System.Configuration;
using System.Text;
using System.Xml;
using System.IO;
using System.Web;
using System.Web.Mail;

namespace mail
{
 /// <summary>
 /// Class1 的摘要说明。
 /// </summary>
 public class mSendMail
 {
  private TcpClient tcpClt;
  private NetworkStream networkStm;
  private Hashtable rightCodeHT = new Hashtable();
  private string smtpServerName;
  private int smtpServerPort;
  private string userName;
  private string passWord;
  private string to;
  private string from;
  private string fromName;
  private string charset;
  private string recipientName;
  private string subject;
  private string body;
  private string priority;

  static string Send_Method;

 

  public mSendMail()
  {

  }

  public mSendMail(string strToName,string strTo,string strBody)
  {
   to = strTo;
   recipientName = strToName;
   body = strBody;
   smtpCodeAdd();
  }
  public  mSendMail(string strToName,string strTo, string strSubject, string strBody)
  {
   to = strTo;
   recipientName = strToName;
   subject = strSubject;
   body = strBody;
   smtpCodeAdd();
  }
  public  mSendMail(string strToName,string strTo,string strFromName,string strFrom, string strSubject, string strBody)
  {
   to = strTo;
   recipientName = strToName;
   from = strFrom;
   fromName = strFromName;
   subject = strSubject;
   body = strBody;
   smtpCodeAdd();
  }
  private bool initialize()
  {
   try
   {
    if(Send_Method=="1")
    {
     smtpServerName = ConfigurationSettings.AppSettings["smtpServerName"];
     smtpServerPort = Convert.ToInt32(ConfigurationSettings.AppSettings["smtpServerPort"]);
     userName = ConfigurationSettings.AppSettings["userName"];
     password = ConfigurationSettings.AppSettings["password"];
     //from = ConfigurationSettings.AppSettings["from"];
     //fromName = ConfigurationSettings.AppSettings["fromName"];
     charset = ConfigurationSettings.AppSettings["charset"];
    }
    else
    {
     smtpServerName ="";//your smtp server
     smtpServerPort =25;
     userName ="";//your name
     password ="";//your pass
     charset ="GB2312";
     //from = ConfigurationSettings.AppSettings["from"];
     //fromName = ConfigurationSettings.AppSettings["fromName"];
    }

 

共6页 首页 上一页 1 2 3 4 5 6 下一页 尾页 跳转到
相关内容
赞助商链接