【发布时间】:2020-11-07 13:30:28
【问题描述】:
我有这段代码可以将我的报告导出为 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.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 并且所有图像都内置在控件本身中
【问题讨论】:
标签: c# winforms outlook xtrareport export-to-html