All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET实现自适应图片大小的弹出窗口(窗口可任意编辑)_[Asp.Net教程]
DB2,9和ASP.NET2.0构建下一代应用程序之二_[Asp.Net教程]
php+xapian,extension的安装_php资料_编程技术
网页特效之HTML中树的实现方法_JavaScript技术_编程技术
asp.net页面导出为Excel文档_[Asp.Net教程]
在asp.net网页中实现tabPage功能(上)_[Asp.Net教程]
C#程序中的DirectShow设计
GridView每页添加不重新开始序号列_[Asp.Net教程]
剖析SQL Server2005 SQLCLR代码安全性_[SQL Server教程]
phpWind中配制伪静态的步骤_[PHP教程]
Reading number is top 10 pictures
乳娘帕梅拉安德森5
这玉米,买还是不卖?
刘亦菲写真集1
这才是真正的人体艺术4
30 beautiful school beauty3
徐若瑄展示美丽胸围1
girl of HuNan name is LiXiang(湖南辣姐李湘的写真)
美丽的桂林风光2
Parking technology is great, that give you the keys can't stolen
A man's favorite things15
Download software ranking
软件工程思想
Unix video tutorial12
Sora aoi‘s film--Lust fan wall
I'm come from Beijing2
电脑知识及技巧大合集
仙剑奇侠传98版歌曲
超级战舰
网络管理员第三版
变速齿轮3.26
Unix video tutorial2
delv published in(发表于) 2014/1/24 9:03:53 Edit(编辑)
asp.net2.0实现邮件发送(成功测试)_[Asp.Net教程]

asp.net2.0实现邮件发送(成功测试)_[Asp.Net教程]

asp.net2.0实现邮件发送(成功测试)_[Asp.Net教程]

1、Default.aspx代码如下:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %>





无标题页











收信:

主题:

内容: Width="336px">

onClick="Button1_Click" />
















onClick="Button2_Click" />









2、Default.aspx.cs代码如下:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//倒入命名空间
using System.Net;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
////设置发件人信箱,及显示名字
MailAddress from = new MailAddress("zgdx0503@cpp114.com", "延边职大信息中心");
//设置收件人信箱,及显示名字
MailAddress to = new MailAddress(TextBox1.Text, "0503班");
//创建一个MailMessage对象
MailMessage oMail = new MailMessage(from, to);

oMail.Subject = TextBox2.Text; //邮件标题
oMail.Body = TextBox3.Text; //邮件内容

oMail.IsBodyHtml = true; //指定邮件格式,支持HTML格式
oMail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");//邮件采用的编码
oMail.Priority = MailPriority.High;//设置邮件的优先级为高

//发送邮件服务器
SmtpClient client = new SmtpClient();
client.Host = "mail.cpp114.com"; //指定邮件服务器
client.Credentials = new NetworkCredential("zgdx0503@cpp114.com", "123456");//指定服务器邮件,及密码

//发送
try
{
client.Send(oMail); //发送邮件
Label1.Text = "恭喜你!邮件发送成功。";
}
catch
{
Label1.Text = "邮件发送失败,检查网络及信箱是否可用。";
}

oMail.Dispose(); //释放资源

TABLE1.Visible = false;
Table2.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
//返回,继续发送
Response.Redirect(Request.Url.ToString());
TABLE1.Visible = true;
Table2.Visible = false;
}
}



3、运行并输入测试信箱zgdx0503@tom.com,(密码:123456)。如下所示:


4、打开信箱查看


来源:csdn







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.