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

Reading number is top 10 articles
Ajax基础必读-AJAX中的一些关键技术_[AJAX教程]
ASP.NET,MVC+LINQ开发一个图书销售站点(9)-编辑目录_[Asp.Net教程]
Asp.net(c#)实现多线程断点续传_[Asp.Net教程]
PHP编程技巧:看实例学正则表达式_php资料_编程技术
SQL,SERVER如何减少死锁_mssql学习_编程技术
PHP实例教程:PHP实现文件安全下载的程序_php资料_编程技术
.NET内置对象之Session对象_[Asp.Net教程]
ASP.NET获取汉字拼音的首字母_[Asp.Net教程]
delphi获取指定磁盘中剩余空间
用ASP.NET开发电子商务网站对数据库表的设计_.net资料_编程技术
Reading number is top 10 pictures
The wise woman of chest1
Terrorist smile the largest human history an explosion1
中国女孩大胆自拍,显露完美身材4
29 the belle stars after bath figure2
Go to the national museum2
Sora aoi on twitter2
9.3阅兵全景图4-陸海空现代化兵种方阵梯队
Fan bingbing black wings for platform and DanLuoWang believes beauty2
这只猪到底犯了什么错?
Sora aoi in China4
Download software ranking
Unix video tutorial6
仙剑奇侠传98硬盘WINXP版
网页特效实例大全
美女写真3
Boxer vs Yellow1
Love the forty days
C#程序员参考手册
中国结婚习俗实录
Tram sex maniac 2 (H) rar bag16
实战黑客不求人
delv published in(发表于) 2014/1/23 3:12:05 Edit(编辑)
ASP.NET技巧:ASP.Net,2.0,发送邮件的代码_[Asp.Net教程]

ASP.NET技巧:ASP.Net,2.0,发送邮件的代码_[Asp.Net教程]

ASP.NET技巧:ASP.Net 2.0 发送邮件的代码_[Asp.Net教程]

  这两天因为要做一个可以收集用户提交信息,然后发送邮件到指定邮箱的网页。在 asp.net 2.0 里面发送邮件可以使用 System.Net.Mail 下面的类。http://www.systemnetmail.com/faq/2.1.aspx 这个地址有 System.Net.Mail 的作者写的仿佛是 MSDN 类似的 Faq,看代码的时候可以参考以下。什么都不说了,下面贴出来代码吧,毕竟代码是最重要的:


1protected void btnSend_Click(object sender, EventArgs e)
2 {
3 MailMessage mailMessage = new MailMessage();
4 string strBody;
5
6 mailMessage.From = new MailAddress("365rss@gmail.com");
7 mailMessage.To.Add("prlibertine@gmail.com");
8 mailMessage.Subject = "365Rss.CN ";
9
10 strBody = "

" + ddlMainTag.SelectedItem.Text + "


";
11 strBody += "

" + tbTag.Text + "




";
12 strBody += "·" + tbAdv.Text;
13
14 sendMail(mailMessage);
15 }
16
17 //SendMail
18 private void sendMail(MailMessage mail)
19 {
20 SmtpClient smtpClient = new SmtpClient();
21 smtpClient.EnableSsl = true;
22 smtpClient.Host = "smtp.gmail.com";
23 smtpClient.Port = 465;
24 smtpClient.Credentials = new NetworkCredential("365rss@gmail.com", "pwd");
25 try
26 {
27 smtpClient.Send(mail);
28 Label1.Text = "ok";
29 }
30 catch
31 {
32 Label1.Text = "false";
33 }
34 }
35








添加到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.