用SQL Server 2005发送邮件的功能


简略介绍SQL Server 2005发送邮件的功能

用SQL Server 2005发送邮件:

  1. EXEC msdb.dbo.sp_send_dbmail  
  2.     @profile_name = 'test',  
  3.     @recipients = 'test1@test.com;test2@test.com',  
  4.     --@recipients = 'test@test.com',  
  5.     @body = '用msdb.dbo.sp_send_dbmail测试发邮件,不用猜了,我是谦',  
  6.     @subject = '测试发邮件 sql查询',  
  7.     @query = ' select 表名=name,类型=case xtype when ''S'' then ''系统表'' else ''用户表'' end from sysobjects where xtype in(''U'',''S'') ',   
  8.     @attach_query_result_as_file = 1,  
  9.     @query_attachment_filename = 'Results.txt'

相关内容