计算机技术联盟
Would you like to react to this message? Create an account in a few clicks or log in to continue.

邮件发送测试--Codebehind

2 posters

向下

邮件发送测试--Codebehind Empty 邮件发送测试--Codebehind

帖子 由 網絡晨曦 周一 三月 10, 2008 12:25 am

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Blood.Com.ClassLib;

namespace Test
{
///
/// 邮件发送例子
///

public class SendMailSample : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.DropDownList ddlPriority;
protected System.Web.UI.WebControls.DropDownList ddlHtml;
protected System.Web.UI.WebControls.TextBox txtSmtpHost;
protected System.Web.UI.WebControls.TextBox txtPort;
protected System.Web.UI.WebControls.TextBox txtFrom;
protected System.Web.UI.WebControls.TextBox txtFromName;
protected System.Web.UI.WebControls.TextBox txtTo;
protected System.Web.UI.WebControls.TextBox txtToName;
protected System.Web.UI.WebControls.TextBox txtSubject;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.RegularExpressionValidator revPort;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvSmtpHost;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvPort;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvFrom;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvTo;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvSubject;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvMessage;
protected System.Web.UI.WebControls.Button btnSendMail;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.RegularExpressionValidator revFrom;
protected System.Web.UI.WebControls.RegularExpressionValidator revTo;
protected System.Web.UI.WebControls.Panel pelMessage;

private void Page_Load(object sender, System.EventArgs e)
{
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.btnSendMail.Click += new System.EventHandler(this.btnSendMail_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnSendMail_Click(object sender, System.EventArgs e)
{
if(IsPostBack)
{
***TPMail clsMail = new ***TPMail();
string strSmtpHost = txtSmtpHost.Text;
int intPort = Int32.Parse(txtPort.Text);
string strFrom = txtFrom.Text;
string strFromName = txtFromName.Text;
string strTo = txtTo.Text;
string strToName = txtToName.Text;
***TPMail.Prioritys Priority = ***TPMail.Prioritys.NORMAL;
bool bolHtml;
string strSubject = txtSubject.Text;
string strMessage = txtMessage.Text;
if(ddlPriority.SelectedItem.Text == "默认")
{
Priority = ***TPMail.Prioritys.NORMAL;
}
else if(ddlPriority.SelectedItem.Text == "高")
{
Priority = ***TPMail.Prioritys.HIGH;
}
else if(ddlPriority.SelectedItem.Text == "低")
{
Priority = ***TPMail.Prioritys.LOW;
}
if(ddlHtml.SelectedItem.Text == "是")
{
bolHtml = true;
}
else
{
bolHtml = false;
}
clsMail.SendMail(strSmtpHost,intPort,strFrom,strFromName,strTo,strToName,Priority,bolHtml,"",strSubject,strMessage);
if(clsMail.ErrorMessage !="")
{
pelMessage.Visible = true;
lblMessage.Text = clsMail.ErrorMessage;
lblMessage.ForeColor = System.Drawing.Color.Red;
}
else
{
pelMessage.Visible = true;
lblMessage.Text = "邮件发送成功";
lblMessage.ForeColor = System.Drawing.Color.Blue;
}
}
}
}
}
網絡晨曦
網絡晨曦
三军统帅
三军统帅

帖子数 : 128
年龄 : 35
注册日期 : 08-03-07

http://hi.baidu.com/%CD%F8%C2%E7%B3%BF%EA%D8

返回页首 向下

邮件发送测试--Codebehind Empty 回复: 邮件发送测试--Codebehind

帖子 由 SamuelFisher 周五 四月 11, 2008 4:36 am

真难,我以前研究过一个简单的,在DOS下输入 telnet www.163.com 110 然后再输入一些数据,具体不记得了,不知道那方法现在还可行不.

SamuelFisher
列兵
列兵

帖子数 : 32
年龄 : 36
注册日期 : 08-03-15

返回页首 向下

返回页首


 
您在这个论坛的权限:
不能在这个论坛回复主题