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"];
}