vendredi 8 mai 2015

Embedding image in email with SQL [sp_send_dbmail]

I want to embed an image into an HTML email with SQL server. The emails are getting sent but the images do not show. My code is as follows:

    DECLARE @body_custom VARCHAR(MAX)
SET @body_custom = '<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="image_1.jpg" width="235" height="70" alt="">
                                </td>
                                <tr>
                                <td valign="top" align="left">
                                    <img src="image_2.png" width="235" height="70" alt="">
                                </td>
                            </tr>
                            <tr>
                                <td valign="top" align="left">
                                    <img src="image_3.gif" width="235" height="70" alt="">
                                </td>
                            </tr>
                            </tr>
                        </table>
                    </body>'
EXEC msdb.dbo.sp_send_dbmail 
    @profile_name = 'Google_Gmail_Account'
    , @recipients = '???@gmail.com'
    , @subject = 'SQl 2008 R2 Email Test'
    , @body = @body_custom
    , @body_format = 'HTML'
    , @file_attachments = 'C:\Users\User\Desktop\image_1.jpg;C:\Users\User\Desktop\image_2.png;C:\Users\User\Desktop\image_3.gif'

This sends the email and the images as attachments, but they do not display in the email.

I have also added the images to my google drive and taken their links and used that, but still no success...

Aucun commentaire:

Enregistrer un commentaire