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

Reading number is top 10 articles
实例:尽可能写友好的javascript代码_JavaScript技术_编程技术
加速动态网站,MySQL索引分析和优化_php资料_编程技术
C#网络应用编程基础练习题与答案(五)_.net资料_编程技术
查询数据库中重复记录的方法_[SQL Server教程]
PHP会话(Session)使用入门
如何在服务端(Page.Write)调用自定义的JS方法_JavaScript技术_编程技术
小结:PHP动态网页程序优化及高效提速问题_php资料_编程技术
叩开C#之门系列之几个重要名词_[Asp.Net教程]
HTML教程-收集的常用的HTML标签(5)_[Html教程]
Apache配置文件里的LogLevel指令介绍_php资料_编程技术
Reading number is top 10 pictures
Born After 90 Beijing sports university campus flower photos1
看到这个手速,决定过年就让我家猫帮我抢红包了。。
The real super beauty4
世界五大海盗
Female model behind the bitterness, often being overcharged3
壮丽的云彩1
Summer is most suitable for young people to travel in China10
Breasts woman big set 1
美女
再发一张清纯美眉的照片
Download software ranking
Boxer's Top ten classic battle1
Tram sex maniac 2 (H) rar bag5
Tram sex maniac 2 (H) rar bag1
Tram sex maniac 2 (H) rar bag4
Kung.Fu.Panda.2
Unix video tutorial8
Eclipse 4.2.2 For Win32
金山office2007
matrix3
Boxer's Top ten classic battle4
aaa published in(发表于) 2013/12/15 8:53:29 Edit(编辑)
技巧:ASP.Net,2.0,发送邮件的代码_.net资料_编程技术

技巧:ASP.Net,2.0,发送邮件的代码_.net资料_编程技术

技巧:ASP.Net 2.0 发送邮件的代码_.net资料_编程技术-你的首页-uuhomepage.com

这两天因为要做一个可以收集用户提交信息,然后发送邮件到指定邮箱的网页。在 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.