0

我想在填充了 SQL Server 表数据的表的列中添加一个图标/图像,并将结果通过电子邮件发送出去。

就目前而言,我在电子邮件中得到的只是

<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 中查看,不会离开内部网络。

任何指针都会很棒!

谢谢

4

1 回答 1

1

希望这可能在某个时间点对某人有用......为了让它工作,我基本上将列转换为表选择中的 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>'

指出所谓的欺骗问题帖子/评论(非常)远远超出了我实际要求的内容。

于 2017-04-07T14:50:32.023 回答