将.msg文件转换为.xps格式?

时间:2012-09-11 09:12:24

标签: c# outlook ms-office xps

我的应用程序将Microsoft Office文档转换为.XPS文件。

我已成功使用Office Interop转换Word,Excel和PowerPoint文件。我无法弄清楚如何对“Outlook邮件格式(.msg)”文件执行相同操作。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

您可以first convert the MSG to DOC HTML MHTML ,然后执行secondary conversion to XPS。 Outlook互操作中没有 MSG XPS 的直接转换支持。

mailItem.SaveAs(targetDoc, Outlook.OlSaveAsType.olDoc); // convert MSG to DOC
// convert DOC as XPS
var wordDocument = wordApplication.Documents.Open(targetDoc);
if (wordDocument != null)
    wordDocument.ExportAsFixedFormat(targetXPS, 
        Word.WdExportFormat.wdExportFormatXPS, paramOpenAfterExport, paramExportOptimizeFor,
        paramExportOptimizeFor, paramExportRange, paramStartPage,
        paramEndPage, paramExportItem, paramIncludeDocProps, 
        paramKeepIRM, paramCreateBookmarks, paramDocStructureTags, 
        paramBitmapMissingFonts, paramUseISO19005_1,
        ref paramMissing);
相关问题