best way to send emails

  • What is the best way to send emails with query results as attachment?

    There is a stored proc sp_send_dbmail but the formatting is not very good.

    Is there any way ,I can improve the look and feel of the text file I email or any other way to do it ?

    Thanks,

  • you can send the mail using sp_send_dbmail this simplest way.

    Syntax:

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'XXXX',

    @recipients = 'XXX@XXX.com',

    @body = 'The stored procedure finished successfully.',

    @subject = 'Automated Success Message' ,

    @query='enter the query'

    @attach_query_result_as_file = 1 ;

    Other way is if you have reporting services installed then you can subscribe the reports its quite nice with formatting future.

    Thank you,

  • Here is an article with examples

    http://jasonbrimhall.info/2011/08/15/send-dbmail/

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • If the results of the query can be sent as the text of the email (in HTML), I highly suggest this stored procedure.

    http://www.virtualobjectives.com.au/sqlserver/saving_to_html.htm

    I've been using it for over a year, and it works well for what I need it to do. I've never formatted the HTML using CSS, but it is an option with this procedure.

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

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