send mail not working when used with attachment

  • 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

  • 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.

  • The script above does indeed work -- the email just went to the junk folder 😀

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply