• Lowell (6/23/2010)


    the secret is to use cid:attachedimage.gif for the source file.

    here's a setup and working example:

    I'm attaching the results of a query, and i copied the SQl server logo to my C:\ drive of my sql server.

    declare @body1 varchar(4000)

    set @body1 = '<head>

    <title> Embedded Logo Example</title>

    <meta name="Generator" content="EditPlus">

    <meta name="Author" content="">

    <meta name="Keywords" content="">

    <meta name="Description" content="">

    </head>

    <body>

    <table><tr><td valign="top" align="left">MyHeader</td></tr>

    <tr><td valign="top" align="left"><img src="cid:sqlservercentral_logo.gif" width="235" height="70" border="0" alt=""></td></tr>

    </table>

    </body>'

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name='MyDefault EmailProfile',

    @recipients='lowell@somedomain.net',

    @subject = 'SQl 2008 email test',

    @body = @body1,

    @body_format = 'HTML',

    @query = 'SELECT top 3 * from sysobjects where xtype=''U''',

    @query_result_header = 0,

    @exclude_query_output = 1,

    @append_query_error = 1,

    @attach_query_result_as_file = 1,

    @query_attachment_filename = 'results.txt',

    @query_result_no_padding = 1,

    @file_attachments = 'C:\sqlservercentral_logo.gif'

    That was it. My other problem was the @file_attachments parameter - I didn't have that. Thank you very much!