sqlserver£¬SQLServerÖз¢ËÍÓʼþµÄз½Ê½½éÉÜ

SQLServerÖз¢ËÍÓʼþµÄз½Ê½½éÉÜ - Ó¦ÓÃÈí¼þ - µçÄԽ̳ÌÍø

SQLServerÖз¢ËÍÓʼþµÄз½Ê½½éÉÜ

ÈÕÆÚ£º2007-07-09   ¼ö£º
¡¡¡¡ËµÊÇз½Ê½£¬ÆäʵҲÊÇÔç¾ÍÓõ½µÄ¼¼ÊõÁË£¬ËùÒÔ·ÅÉÏÀ´£¡¡¡¡¡¡¡¡¡ÔÚ.NETÖУ¬´ó¼ÒÖªµÀ£¬¿ÉÒÔʹÓÃSystem.Web.MailÀ´·¢ËÍÓʼþ¡£ÔÚFramework 1.1ÏÂÖ§³ÖÑéÖ¤¡£¡¡¡¡¡¡¡¡private void Page_Load(object sender, System.EventArgs e)¡¡¡¡{¡¡¡¡MailMessage mail = new MailMessage();¡¡¡¡mail.To = "[email protected]";¡¡¡¡mail.From = "[email protected]";¡¡¡¡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://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'¡¡¡¡EXEC @hr = sp_OASetProperty @object, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value', 'smtp.163.com'¡¡¡¡¡¡¡¡--ÏÂÃæÈýÌõÓï¾äÊÇsmtpÑéÖ¤£¬Èç¹û·þÎñÆ÷ÐèÒªÑéÖ¤£¬Ôò±ØÐëÒªÕâÈý¾ä£¬ÄãÐèÒªÐÞ¸ÄÓû§ÃûºÍÃÜÂë¡¡¡¡EXEC @hr = sp_OASetProperty @object, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value','1'¡¡¡¡EXEC @hr = sp_OASetProperty @object, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusername").Value','lihonggen0'¡¡¡¡EXEC @hr = sp_OASetProperty @object, 'Configuration.fields("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¶ÔÏó
±êÇ©£º