我有这段代码可以将我的报告导出为 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 并且所有图像都内置在控件本身中