2

我有 1000 封电子邮件(.msg 格式),我想将它们转换为 PDF 文件。
阅读 .MSG 文件已经被问到这里

但对我来说,问题是像从“文件 - > 打印”一样打印 .msg 电子邮件。

有没有一种简单的方法可以将 .msg 电子邮件打印为 PDF?

4

3 回答 3

0

如果您希望以编程语言实现解决方案,而不是手动打印每条消息,您可以考虑使用 Aspose.Network 和 Aspose.Words for .NET 组件。他们一起工作将 MSG 文件转换为 PDF。

  1. Aspose.Network for .NET 用于加载 MSG 并保存为 MHTML 格式
  2. Aspose.Words for .NET 用于加载 MHTML 并生成 PDF 或任何其他支持的格式

查看此页面上的示例代码。它对 TIFF 进行 MSG,但您可以稍微修改并提供任何支持的格式,包括 PDF、DOC、DOCX 等。

于 2011-04-21T19:59:05.440 回答
0
    Dim objItem, objFSO, strFile, input, fileExt, strHtml, strPdf, msg,    wordDoc, wordApp, tempFileFolder

    Const olFormatHTML = 5
    Const wdFormatPDF = 17


    input = Wscript.Arguments(0)

    ' Create a File System object
    Set objFSO = CreateObject( "Scripting.FileSystemObject" )

     ' Check if the Word document exists
    If objFSO.FileExists(input) Then
        Set objItem = objFSO.GetFile(input)
        strFile = objItem.Path  
    Else
        WScript.Echo "FILE OPEN ERROR: The file does not exist" & vbCrLf
        WScript.Quit
    End If

    fileExt = Right(strFile,3)

    If fileExt <> "msg" Then
        WScript.Echo "FILE ERROR: The file extension is not .msg" & vbCrLf
        WScript.Quit
    End If

    strHtml = objItem.Path + ".html"
    strPdf = objItem.Path + ".pdf"

    Set Outlook = CreateObject("Outlook.Application")
    Set msg = Outlook.CreateItemFromTemplate(objItem.Path) 
    msg.SaveAs strHtml, olFormatHTML
    Outlook.Quit

    Set wordApp = CreateObject( "Word.Application" )    
    wordApp.Documents.Open strHtml
    Set wordDoc = wordApp.ActiveDocument
    wordDoc.SaveAs strPdf, wdFormatPDF
    wordDoc.Close
    wordApp.Quit


    If objFSO.FileExists(strHtml) Then
        objFSO.DeleteFile(strHtml)
    End If

    tempFileFolder = objItem.Path & "_files"
    If objFSO.FolderExists(tempFileFolder) Then
        objFSO.DeleteFolder(tempFileFolder)
    End If
于 2013-10-18T05:04:23.273 回答
-1

您可以使用MsgViewer Pro 之类的应用程序。

它具有“从命令行打印”功能,您可以在批处理模式下使用它。

注意:我没有使用这个查看器,但我认为这可能是一个很好的建议。

于 2011-03-24T08:59:22.787 回答