.chinacs.*** 2002-5-9 中文c#技術站
郵件傳送類,支援html格式,支援優先順序設定。通過socket類實現的
using system;
using system.text;
using system.io;
using system.***;
using system.***.sockets;
namespace blood.***.classlib
public void send***mandtoserver(string ***mand)
public string getserverresponse()
else }
public bool doesstringcontain**tpcode(string s,string **tpcode)
} //結束類
///
/// 傳送郵件類
///
public class **tpmail
///
/// 取得錯誤反饋資訊
///
public string errormessage
}///
/// 取得**tp伺服器反饋的資訊
///
public string serverresponse
}///
/// 郵件傳送優先順序
///
public enum prioritys
public void sendmail(string **tphost,int port,string from,string displayfromname,string to,string displaytoname,prioritys priority,bool html,string base,string subject,string message)
//讀取反饋資訊
strresponsenumber = **tpcmail.getserverresponse();
if (**tpcmail.doesstringcontain**tpcode(strresponsenumber,"220"))
else
string strsendbuffer = new string[6];
string strresponsecode = ; // success codes from **tp server
string strdata = "";
strdata = string.concat("helo ",**tphost);
strdata = string.concat(strdata,"/r/n");
strsendbuffer[0] = strdata ;
strdata = "";
strdata = string.concat("mail from: ","<" + from + ">");
strdata = string.concat(strdata,"/r/n");
strsendbuffer[1] = strdata;
strdata = "";
strdata = string.concat("rcpt to: ","<" + to + ">");
strdata = string.concat(strdata,"/r/n");
strsendbuffer[2] = strdata;
strdata = "" ;
strdata = string.concat("data","/r/n");
strsendbuffer[3] = strdata ;
strdata = "" ;
strdata = string.concat("from: ",displayfromname + "<" + from + ">");
strdata = string.concat(strdata,"/r/n" );
strdata = string.concat(strdata,"to: " );
strdata = string.concat(strdata,displaytoname + "<" + to + ">");
strdata = string.concat(strdata,"/r/n" );
strdata = string.concat(strdata,"subject: " );
strdata = string.concat(strdata,subject);
strdata = string.concat(strdata,"/r/n");
strdata = string.concat(strdata,"mime-version: 1.0" );
strdata = string.concat(strdata,"/r/n");
strdata = string.concat(strdata,"x-priority: " + priority);
strdata = string.concat(strdata,"/r/n");
strdata = string.concat(strdata,"x-m**ail-priority: " + priority);
strdata = string.concat(strdata,"/r/n");
if(html == true)
else
strdata = string.concat(strdata,"/r/n");
strdata = string.concat(strdata,"charset=/"iso-8859-1/"" );
strdata = string.concat(strdata,"/r/n");
if(html == true)
else
strdata = string.concat(strdata,"/r/n");
strdata = string.concat(strdata,"content-base: /"" + base + "/"" );
strdata = string.concat(strdata,"/r/n" + "/r/n");
strdata = string.concat(strdata,message);
strdata = string.concat(strdata,"/r/n./r/n");
strsendbuffer[4] = strdata;
strdata = "" ;
strdata = string.concat(strdata,"quit/r/n");
strsendbuffer[5] = strdata;
int i = 0 ;
while(i < strsendbuffer.length)
// 結束迴圈
}catch(socketexception err)
catch(exception e)
} //結束郵件傳送方法
} // 結束類
} // 結束namespace
郵件傳送前台頁面
<%@ page language="c#" codebehind="webform1.aspx.cs" autoeventwireup="false" inherits="test.sendmailsample" %>
郵件傳送codebehind
using system;
using system.web;
using system.web.ui;
using system.web.ui.webcontrols;
using blood.***.classlib;
namespace test
#region web form designer generated code
override protected void oninit(eventargs e)
///
/// required method for designer support - do not modify
/// the contents of this method with the code editor.
///
private void initialize***ponent()
#endregion
private void btnsendmail_click(object sender, system.eventargs e)
else if(ddlpriority.selecteditem.text == "高")
else if(ddlpriority.selecteditem.text == "低")
if(ddlhtml.selecteditem.text == "是")
else
cl**ail.sendmail(str**tphost,intport,strfrom,strfromname,strto,strtoname,priority,bolhtml,"",strsubject,strmessage);
if(cl**ail.errormessage !="")
else}}
}}
郵件傳送類,支援HTML格式,支援優先順序設定
郵件傳送類,支援html格式,支援優先順序設定。通過socket類實現的 using system using system.text using system.io using system.net using system.net.sockets namespace blood.com.clas...
郵件傳送類,支援HTML格式,支援優先順序設定
www.chinacs.net2002 5 9中文c 技術站 郵件傳送類,支援html格式,支援優先順序設定。通過socket類實現的 using system using system.text using system.io using system.net using system.net.s...
傳送郵件,支援群發,非常好用
傳送郵件 public class smtpmanager else mail.to.add newmailaddress address,displayname 設定郵件的抄送收件人 這個就簡單多了,如果不想快點下崗重要檔案還是cc乙份給領導比較好 mailaddress manage hotma...