SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


send mail not working when used with attachment


send mail not working when used with attachment

Author
Message
sierra4
sierra4
SSC Veteran
SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)

Group: General Forum Members
Points: 283 Visits: 677
hi,

below is the script i have in SQL Server Agent.

SET ROWCOUNT 0
EXEC msdb..sp_send_dbmail
@profile_name = 'SQL Mail',
@recipients = '<me@email.com>',
@subject = 'subject',
@body = 'Please see attached report',
@file_attachments = 'D:\MSSQL10.MSSQLSERVER\MSSQL\Log\output_report_3.txt'
--@query = 'sp_helpdb userdb',
--@execute_query_database = 'MSDB',
--@query_result_separator = ',',
go

the job completes successfully but does not send an email. there are no errors generated.

when i comment out @file_attachments, and instead uncomment the @query parameters then i do receive an email

what am i missing with the @file_attachments parameter?

thank you
mbhandari
mbhandari
SSC-Enthusiastic
SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)

Group: General Forum Members
Points: 100 Visits: 269
The query looks good. I don't think there is any additional arguments to be passed for attachements. The only thing I would like to point out is SQL Server limits the size of attachment to 1 MB by default.
sierra4
sierra4
SSC Veteran
SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)SSC Veteran (283 reputation)

Group: General Forum Members
Points: 283 Visits: 677
The script above does indeed work -- the email just went to the junk folder :-D
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search