how to send a mail with attachment

  • Hi,

    I want to send a mail with database table values as html file.How to send a mail with attachment.Give your suggestions on this.

    Thanks,

  • Hey,

    You'll need to build a query driven email and format as HTML. The following stored procedure will help you and BOL has more details:

    sp_send_dbmail [ [ @profile_name = ] 'profile_name' ]

    [ , [ @recipients = ] 'recipients [ ; ...n ]' ]

    [ , [ @copy_recipients = ] 'copy_recipient [ ; ...n ]' ]

    [ , [ @blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]

    [ , [ @subject = ] 'subject' ]

    [ , [ @body = ] 'body' ]

    [ , [ @body_format = ] 'body_format' ] [ , [ @importance = ] 'importance' ]

    [ , [ @sensitivity = ] 'sensitivity' ]

    [ , [ @file_attachments = ] 'attachment [ ; ...n ]' ]

    [ , [ @query = ] 'query' ] [ , [ @execute_query_database = ] 'execute_query_database' ]

    [ , [ @attach_query_result_as_file = ] attach_query_result_as_file ]

    [ , [ @query_attachment_filename = ] query_attachment_filename ]

    [ , [ @query_result_header = ] query_result_header ]

    [ , [ @query_result_width = ] query_result_width ]

    [ , [ @query_result_separator = ] 'query_result_separator' ]

    [ , [ @exclude_query_output = ] exclude_query_output ]

    [ , [ @append_query_error = ] append_query_error ]

    [ , [ @query_no_truncate = ] query_no_truncate ]

    [ , [ @query_result_no_padding = ] query_result_no_padding ]

    [ , [ @mailitem_id = ] mailitem_id ] [ OUTPUT ]

    Thanks,

    Phillip Cox

  • How does it taks query result as file and attach it to send mail task.Can you explain if you have any idea with example.

    Thanks,

    Ramu

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

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