2017-04-06 64 views
0

我想在填充了SQL Server表數據的表的列中添加圖標/圖像&將生成的電子郵件發送出去。將圖像插入到SQL Server存儲過程中的HTML表中,以便與DBMail一起使用

因爲它代表所有我收到的電子郵件是

<img src="cid:RedTL.gif"/> 

我的代碼:

--Full path set within attachments 
@file_attachments='E:\RedTL.gif', 

SET @TBLHTML= 
     N'<STYLE type="text/css">' + 
     N'.Table { background-color:#D8E7FB;border-collapse:separate;color:#000;font-size:18px; }' + 
     N'.Table th { background-color:#0E0355;color:white; }' + 
     N'.Table td, .Table th { padding:5px;border:0; }' + 
     N'.Table td { border: 1px dotted white; }' + 
     N'</STYLE>' + 
     N'<table class="Table">' + 
     N'<th><font face="calibri" size="2">Column1</th>' + 
     N'<th><font face="calibri" size="2">Image Column</font></th>' + 
     N'<th><font face="calibri" size="2">Column3</font></th>' + 
     N'<th><font face="calibri" size="2">Column4</font></th>' + 
     N'<th><font face="calibri" size="2">Column5</font></th>' + 
     N'<th><font face="calibri" size="2">Column6</font></th>' + 
     CAST (( SELECT td=[Column1],'', 
          --filename is referenced 
          td='<img src="RedTL.gif"/>','', 
          td=[Column2],'', 
          td=[Column3],'', 
          td=[Column4],'', 
          td=[Column5],'' 
        FROM [Table1] 
        ORDER BY [Column1] 
        FOR XML PATH('tr'), TYPE 
     ) AS NVARCHAR(MAX)) + 
     N'</table>' 

我有其他圖像嵌入很好,只是具有嵌入表中的一個問題。

將在Outlook中查看電子郵件&不會離開內部網絡。

任何指針都會棒極了!

感謝

+0

我認爲你應該嵌入圖像,而不是指向一個路徑 – TheGameiswar

+1

這是完全相似的,幷包含源代碼示例以及:http://stackoverflow.com/questions/6706891/embedding-image-in-html-email – TheGameiswar

+0

可能重複[嵌入圖像在HTML電子郵件](http://stackoverflow.com/questions/6706891/embedding-image-in-html-email) – TheGameiswar

回答

0

希望這可能在某個時間點是使用的人的.....得到它的工作我基本投欄作爲XML表中選擇的'設置針對每個因爲它們根據日期而不同,所以它實際上非常簡單;

SET @TBLHTML= 
     N'<STYLE type="text/css">' + 
     N'.Table { background-color:#D8E7FB;border-collapse:separate;color:#000;font-size:18px; }' + 
     N'.Table th { background-color:#0E0355;color:white; }' + 
     N'.Table td, .Table th { padding:5px;border:0; }' + 
     N'.Table td { border: 1px dotted white; }' + 
     N'</STYLE>' + 
     N'<table class="Table">' + 
     N'<th><font face="calibri" size="2">Case Attorney</th>' + 
     N'<th><font face="calibri" size="2">TL Status</font></th>' + 
     N'<th><font face="calibri" size="2">Event Due Date</font></th>' + 
     N'<th><font face="calibri" size="2">Event Description</font></th>' + 
     N'<th><font face="calibri" size="2">Event No.</font></th>' + 
     N'<th><font face="calibri" size="2">Client</font></th>' + 
     N'<th><font face="calibri" size="2">Applicant</font></th>' + 
     CAST (( SELECT td=[CaseAtt],'', 
          td=CAST([TLImage] AS XML),'', 
          td=CONVERT(VARCHAR(12),[EventDueDate],103),'', 
          td=[EventDesc],'', 
          td=[EventNo.],'', 
          td=[Client],'', 
          td=[Applicant],'' 
        FROM #TLREP 
        ORDER BY [CaseAtt] 
        FOR XML PATH('tr'), TYPE 
     ) AS NVARCHAR(MAX)) + 
     N'</table>' 

指出假設的愚蠢問題帖子/評論是(非常)廣泛的我實際上要求。

相關問題