Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Trying to send an attachement but no luck.

Author  Topic 

Movva
Starting Member

15 Posts

Posted - 2011-08-16 : 11:55:25
Hi,

I am trying to send an attachement using the sp_send_dbmail store proc. Here is how I am trying to do

EXEC msdb.dbo.sp_send_dbmail
@recipients=@email_addresses,
@query = @query1,
@subject = @subject_text,
@body = @message_txt,
@body_format = 'HTML',
@attach_query_result_as_file = 1,
@query_result_header = 0,
@exclude_query_output = 1,
@file_attachments = @icsfilename,
@query_result_width = 250

It doesn't throw any errors but I do not see the atleast email being sent. But when I comment @query, @file_attachments, @attach_query_result_as_file parameters I get the email but no attachements. Am I missing some thing here? I test my @query1 values and looks alright. Can some one please help?

Thanks,

L

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-17 : 04:37:17
is the query returning anything at all? first check that

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-08-18 : 04:51:33
try to use path of the file and test use single quote for file path.
Go to Top of Page
   

- Advertisement -