如何将 .MSG 打印为 PDF

发布于 2024-10-20 20:38:35 字数 231 浏览 7 评论 0原文

我有 1000 封电子邮件(.msg 格式),我想将它们转换为 PDF 文件。
此处已询问读取 .MSG 文件。

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

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

I have 1000 emails (in .msg format) and I'd like to convert those to PDF files.
Reading .MSG file has already been asked here.

But the problem for me is to print .msg emails as you do from "File -> Print".

Is there a simple way to print .msg emails to PDF?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痴梦一场 2024-10-27 20:38:35

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

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

请参阅 此页面< /a>.它可以将 MSG 转换为 TIFF,但您可以稍微修改并提供任何支持的格式,包括 PDF、DOC、DOCX 等。

If you want a solution implemented in a programming language instead of manually printing each message, you may consider using Aspose.Network and Aspose.Words for .NET components. They work together to convert MSG file to PDF.

  1. Aspose.Network for .NET for loading the MSG and saving as MHTML format
  2. Aspose.Words for .NET for loading the MHTML and producing the PDF or any other supported format

Have a look at the sample code at this page. It does MSG to TIFF, but you may slightly modify and give any supported format including PDF, DOC, DOCX etc.

秋风の叶未落 2024-10-27 20:38:35
    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
    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
捶死心动 2024-10-27 20:38:35

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

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

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

You could use an application like MsgViewer Pro .

It has a "print from command line" feature which you could probably use in a batch mode.

Note: I did not use this viewer, but I thought it might be a good suggestion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文