How can we encode the image into the body of the email when sending mail using database mail in sql 2008?

1.6k views Asked by At

How can we encode the image into the body of the email when sending mail using database mail in sql 2008 I m using :

    exec msdb.dbo.sp_send_dbmail
    @profile_name = 'DBMail',
    @recipients = '[email protected]',
    @subject = 'DB hello',
    --@file_attachments = 'C:\logo.jpg',    
    @body='<p>Image Test</p><img src="C:\logo.jpg" width="270" height="146"" /><p>See image there?</p>' , 
    @body_format = 'HTML';

Any help would be highly appreciable.. Thanks

1

There are 1 answers

0
Michał Powaga On

You've almost done it:

exec msdb.dbo.sp_send_dbmail
@profile_name = 'DBMail',
@recipients = '[email protected]',
@subject = 'DB hello',
@file_attachments = 'C:\logo.jpg;C:\logo2.jpg;',    
@body='<p>Image Test</p><img src="logo.jpg" width="270" height="146"" /><p>See image there?</p><img src="logo2.jpg" width="270" height="146"" />' , 
@body_format = 'HTML';

Attach required images using @file_attachments separate them using ; an then use their names (only file name with extension) in @body.