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

Reading number is top 10 articles
SQL,Server,2005,Express,Edition安装步骤详解_mssql学习_编程技术
用ADO管理SQL,Server数据库_[SQL,Server教程]
了解ASP2.0向其它网页传递信息的方法_[Asp.Net教程]
利用C#实现标注式消息提示窗口_.net资料_编程技术
实用技巧 利用Apache实现禁止图片盗链_[PHP教程]
Asp.net,2.0,GridView数据导出Excel文件(示例代码下载)_[Asp.Net教程]
实例研究PHP函数isset和empty的区别_php资料_编程技术
asp.net显示下载提示的下载网页程序_[Asp.Net教程]
Asp.Net对Xml文件的操作_[Asp.Net教程]
Asp.Net中动态页面转静态页面_[Asp.Net教程]
Reading number is top 10 pictures
The money of more than 100 countries and regions10
西游四格漫画(四)
So beauty, will let you spray blood1
Discharge accidentally Actresses by the breast4
Sora aoi possession of boudoir1
明星与豪宅
2015中美最新武器装备巅峰对决!
The world first motorcycle will be auctioned for 21000 pounds
A man's favorite things16
心有鱼而力不足
Download software ranking
金山office2007
Unix video tutorial5
C语言教程TXT
Tram sex maniac 2 (H) rar bag8
Tram sex maniac 2 (H) rar bag17
Boxer's Top ten classic battle2
Boxer's Top ten classic battle4
Ashlynn Video3
C#与.NET技术平台实战演练
尖东毒玫瑰A
归海一刀 published in(发表于) 2014/2/1 0:11:54 Edit(编辑)
SQL,Server中发送邮件的新方式_[SQL,Server教程]

SQL,Server中发送邮件的新方式_[SQL,Server教程]

SQL Server中发送邮件的新方式_[SQL Server教程]

在.NET中,大家知道,可以使用System.Web.Mail来发送邮件。在Framework 1.1下支持验证。private void Page_Load(object sender, System.EventArgs e)
  {

  MailMessage mail = new MailMessage();
  mail.To = "me@mycompany.com";
  mail.From = "you@yourcompany.com";
  mail.Subject = "this is a test email.";
  mail.Body = "Some text goes here";
  mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
  mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
  mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here
  SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
  SmtpMail.Send( mail );
  }
  以前我曾写过在.NET下发送邮件的方法,详见:
  http://dev.csdn.net/develop/article/17/17189.shtm
  SQL Server中,我们一般使用SQL本身的邮件发送方式,但需要配置Exchage Server、Outlook等,也是一个比较繁琐的事情。很多人抱怨说配置不成功。
  其实,我们可以在 SQL Server中创建 OLE 对象实例,调用IIS SMTP自带的发送组件来实现邮件发送。
  我们建立这个存储过程,你需要修改的地方是,SmtpServer的名字
  Create PROCEDURE sys_sendmail @From varchar(100) , @To varchar(100) , @Bcc varchar(500), @Subject varchar(400)=" ", @Body ntext =" "
  AS
  Declare @object int
  Declare @hr int
  EXEC @hr = sp_OACreate ’CDO.Message’, @object OUT
  EXEC @hr = sp_OASetProperty @object, ’Configuration.fields("http://news.softhouse.com.cn/news/show/’http://schemas.microsoft.com/cdo/configuration/sendusing").Value’,’2’’
  EXEC @hr = sp_OASetProperty @object, ’Configuration.fields("http://news.softhouse.com.cn/news/show/’http://schemas.microsoft.com/cdo/configuration/smtpserver").Value’’, ’smtp.163.com’
  --下面三条语句是smtp验证,如果服务器需要验证,则必须要这三句,你需要修改用户名和密码
  EXEC @hr = sp_OASetProperty @object, ’Configuration.fields("http://news.softhouse.com.cn/news/show/’http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value’,’1’’
  EXEC @hr = sp_OASetProperty @object, ’Configuration.fields("http://news.softhouse.com.cn/news/show/’http://schemas.microsoft.com/cdo/configuration/sendusername").Value’,’lihonggen0’’
  EXEC @hr = sp_OASetProperty @object, ’Configuration.fields("http://news.softhouse.com.cn/news/show/’http://schemas.microsoft.com/cdo/configuration/sendpassword").Value’,’xxx’’
  EXEC @hr = sp_OAMethod @object, ’Configuration.Fields.Update’, null
  EXEC @hr = sp_OASetProperty @object, ’To’, @To
  EXEC @hr = sp_OASetProperty @object, ’Bcc’, @Bcc
  EXEC @hr = sp_OASetProperty @object, ’From’, @From
  EXEC @hr = sp_OASetProperty @object, ’Subject’, @Subject
  EXEC @hr = sp_OASetProperty @object, ’TextBody’, @Body
  EXEC @hr = sp_OAMethod @object, ’Send’, NULL
  --判断出错
  IF @hr <> 0
  BEGIN
  EXEC sp_OAGetErrorInfo @object
  RETURN @object
  END
  PRINT ’success’
  EXEC @hr = sp_OADestroy @object
  GO 注意:必须确保安装Smtp,可以访问CDO对象。





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