日期:2014-05-17  浏览次数:20805 次

sql2008 r2发送邮件(添加附件)
我想用数据库作业代理发送邮件,但是需要将附件一起发送,邮件发送已经搞定,但是不知道怎么添加附件,如图所示

------解决方案--------------------
这个参数@file_attachments 制定要发生的附加的文件名列表。


可以参考一下:
SQL SERVER2005发送邮件  
http://blog.163.com/ckj1997@126/blog/static/2819823020103268440440/

------解决方案--------------------
sp_send_dbmail [ [ @profile_name = ] 'profile_name' ]
[ , [ @recipients = ] 'recipients [ ; ...n ]' ]
[ , [ @copy_recipients = ] 'copy_recipient [ ; ...n ]' ]
[ , [ @blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]
[ , [ @subject = ] 'subject' ] 
[ , [ @body = ] 'body' ] 
[ , [ @body_format = ] 'body_format' ]
[ , [ @importance = ] 'importance' ]
[ , [ @sensitivity = ] 'sensitivity' ]
[ , [ @file_attachments = ] 'attachment [ ; ...n ]' ]
[ , [ @query = ] 'query' ]
[ , [ @execute_query_database = ] 'execute_query_database' ]
[ , [ @attach_query_result_as_file = ] attach_query_result_as_file ]
[ , [ @query_attachment_filename = ] query_attachment_filename ]
[ , [ @query_result_header = ] query_result_header ]
[ , [ @query_result_width = ] query_result_width ]
[ , [ @query_result_separator = ] 'query_result_separator' ]
[ , [ @exclude_query_output = ] exclude_query_output ]
[ , [ @append_query_error = ] append_query_error ]
[ , [ @query_no_truncate = ] query_no_truncate ]
[ , [ @mailitem_id = ] mailitem_id ] [ OUTPUT ]

[ @file_attachments = ] 'file_attachments', 
电子邮件附件的文件名列表,以分号分隔。必须使用绝对 路径指定列表中的文件。附件列表的类型为 nvarchar(max)