我尝试过这段代码但不适合我...
EXEC msdb.dbo.sp_send_dbmail
@profile_name='Capricorn',
@recipients='abc@gmail.com',
@query= N'set nocount on;select ClientID,ClientName from ClientMaster; set nocount off;',
@subject='Invoice Not Post',
@query_attachment_filename='Customers.xlsx',
@attach_query_result_as_file = 1,
@body=@body,
@body_format ='HTML'