C# 将报表导出为outlook邮件时嵌入的图像为html
我有这段代码,可以将我的报告导出为html,然后在outlook正文中显示它C# 将报表导出为outlook邮件时嵌入的图像为html,c#,winforms,outlook,xtrareport,export-to-html,C#,Winforms,Outlook,Xtrareport,Export To Html,我有这段代码,可以将我的报告导出为html,然后在outlook正文中显示它 Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
using (RepProjectInfoCH report = new RepProjectInfoCH())
{
report.DataSource = await ProjInfo.RepProjectInfoCH(idProject).ConfigureAwait(true);
string str;
MemoryStream ms = new MemoryStream();
try
{
report.ExportToHtml(ms);
ms.Seek(0, SeekOrigin.Begin);
using (StreamReader sr = new StreamReader(ms))
{
str = sr.ReadToEnd();
}
}
finally
{
ms.Close();
}
oMsg.To = "Test@Test.com";
oMsg.Subject = "Test" ;
oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
oMsg.Display(false); //In order to display it in modal inspector change the argument to true
oMsg.HTMLBody = str + oMsg.HTMLBody; //Here comes your body;
}
除了我的outlook正文中没有显示图像外,其他一切都进行得很顺利。我期望:
但我明白了:
我试着用
HtmlExportOptions htmlOptions = report.ExportOptions.Html;
htmlOptions.EmbedImagesInHTML = true;
但它似乎只适用于xrPictureBox,我使用xrCheckBox,所有图像都内置在控件中Outlook支持HTML图像作为指向web服务器上文件的外部链接或作为附件的引用—在后一种情况下,HTML正文通过
img
选项卡的src=cid:xyz
属性引用图像附件,其中“xyz”是附件上的PR\u ATTACH\u CONTENT\u ID
属性的值。有关更多详细信息,请参阅
请注意,Outlook不支持base64编码的嵌入式图像-这是一个字数限制(Word在Outlook中呈现HTML邮件)。对于延迟,我深表歉意,感谢您的帮助。不幸的是,我采取了简单的方法,用xrPictureBox替换了所有的xrCheckBox。以后我会试试你的方法。再次非常感谢。