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

Reading number is top 10 articles
delphi不同程序间的拖曳操作方法-实例
PHP5,OOP编程之代理与定制异常_php资料_编程技术
Debian下Apache2+Mysql5+Php5的安装配置_php资料_编程技术
初学:在PHP网站开发中如何使用cookies?_php资料_编程技术
SQL Server 2000 中使用正则表达式_[SQL Server教程]
Apache小技巧五则_php资料_编程技术
ASP.NET程序实现三色交替的下拉列表框_[Asp.Net教程]
SQL中的全文检索_[SQL,Server教程]
SQL SERVER 2000 数据库备份与还原_[SQL Server教程]
迁移你的Web页面到ASP.NET,AJAX,1.0_.net资料_编程技术
Reading number is top 10 pictures
The cat shit
运动的范冰冰2
Take you to walk into the most true north Korea rural4
陪睡门马睿菈自曝写真 称首拍大尺度照片3
Azusa Yamamoto1
Ashlynn Brooke photograph of a group4
乳娘帕梅拉安德森3
Photographed the passion of the clients and prostitutes in the sex trade picture2
海底兵马俑
什么叫国家
Download software ranking
Tram sex maniac 2 (H) rar bag13
c#程序设计案例教程
C#程序员参考手册
株洲本地在线棋牌游戏
网络管理员第三版
卡丁车单机版
matrix3
Dance with duck(male prostitution)
Tram sex maniac 2 (H) rar bag15
Take off clothes to survival
归海一刀 published in(发表于) 2014/1/30 1:20:23 Edit(编辑)
Asp.Net发送电子邮件程序_[Asp.Net教程]

Asp.Net发送电子邮件程序_[Asp.Net教程]

Asp.Net发送电子邮件程序_[Asp.Net教程]
一、asp.net1.0及.net1.1中的做法(利用CDOSYS消息组件发送电子邮件):
  代码如下:
  using System;
  using System.Web.Mail;
  ///
  /// 用到的类主要位于System.Web.Mail命名空间下
  ///

  public class SendMail
  {
  public SendMail()
  {
  }
  ///
  /// 发送邮件
  ///

  /// 收件人邮件地址
  /// 发件人邮件地址
  /// 邮件主题
  /// 邮件内容
  /// 登录smtp主机时用到的用户名,注意是邮件地址’@’以前的部分
  /// 登录smtp主机时用到的用户密码
  /// 发送邮件用到的smtp主机
  public void Send(string to, string from, string subject, string body, string username, string password, string smtpHost)
  {
  MailMessage mail = new MailMessage();
  mail.To = to;//设置收件人地址
  mail.From = from;//设置发件人地址
  mail.Subject = subject;//设置邮件主题
  mail.BodyFormat = MailFormat.Html;//设置邮件以HTML格式发送
  mail.Body = body;//设置邮件内容
  //设置发送邮件时需要身份验证
  mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
  //设置登录邮件主机时的用户名,注意如果发件人地址是abc@def.com,则用户名是abc而不是abc@def.com
  mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
  //设置登录SMTP主机的用户密码
  mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
  //设置发送邮件的SMTP主机
  SmtpMail.SmtpServer = smtpHost;
  //发送邮件,如果发送不成功会抛出异常
  SmtpMail.Send(mail);
  }
  }
  上面的方法底层用到了CDOSYS组件,用到的类主要是System.Web.Mail.SmtpServer和System.Web.Mail.MailMessage,这种方法已经被微软不赞成使用了,取而代之的是.net2.0中的新增的类和方法。



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