2012-04-12 47 views
2

我正在使用SQL Server 2008中的sp_send_dbmail發送HTML電子郵件。我可以參考像<網址的圖像img src =「http:...」/>如何引用附件中的圖像

我附加了圖像與@file_attachments。如何在附件中引用此圖像?

感謝

+0

可能重複[可以HTML電子郵件正文引用...附件...](http://stackoverflow.com/questions/9983248/can-an-html-email-body-reference-a-file -sent-as-an-attachment-in-the-same-email) – 2012-04-12 03:47:39

+0

我在SQL Server t-sql中這樣做。如何獲得「Content-ID」「」? – Squirrel 2012-04-12 03:55:14

回答

2
EXEC msdb.dbo.sp_send_dbmail 
    @recipients = '[email protected]', 
    @subject = 'test', 
    @file_attachments = 'C:\Test\Image.gif;C:\Test\Image2.gif', 
    @body=N'<p>Image Test</p><img src="Image.gif" /><p>See image there?</p>', 
    @body_format = 'HTML'; 

希望有所幫助。

下面是我使用的確切代碼,它對我來說工作得很好。

EXEC msdb.dbo.sp_send_dbmail 
    @recipients = '[email protected]', 
    @subject = 'test', 
    @profile_name = 'global config', 
    @file_attachments = 'C:\testimage.png', 
    @body=N'<p>Image Test</p><img src="testimage.png" /><p>See image there?</p>', 
    @body_format = 'HTML'; 

我希望這有助於。

+0

如果我的@file_attachments ='C:\ logo.png' Squirrel 2012-04-12 03:57:54

+0

thanks. i will give it a try – Squirrel 2012-04-12 04:08:22

+0

Sorry, it does not work. The image is not shown. Just a white box instead – Squirrel 2012-04-12 04:12:24