Convert Microsoft Outlook MSG Email Message to PDF File
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Convert Microsoft Outlook MSG Email Message to PDF File

  1. #1
    Join Date
    May 2013
    Posts
    83

    Convert Microsoft Outlook MSG Email Message to PDF File

    This technical tip explains how to convert an email message to PDF using Aspose.Email. Aspose.Email for .NET deals with network protocols and Microsoft Outlook features, and cannot handle direct conversion to PDF. To overcome this, the samples in this article use Aspose.Email to convert the email message to MHTML stream and then use Aspose.Words for .NET to load the MHTML stream and then save it as PDF. The following code shows converting email message to PDF using Aspose.Email in combination with Aspose.Words for .NET. This involves the following steps:

    1. Load the email message using MailMessage
    2. Save the email message to MemoryStream as MHTML
    3. Load the stream using Aspose.Words
    4. Save the message as PDF


    Sample Code for Converting an Email Message to PDF


    [C#]

    Code:
    MailMessagemailMsg = MailMessage.Load("About Aspose-1.msg");
    
    MemoryStreamms = new MemoryStream();
    
    //Save as MHTML
    mailMsg.Save(ms, MailMessageSaveType.MHtmlFromat);
    
    //create an instance of LoadOptions and set the LoadFormat to Mhtml
    varloadOptions = new Aspose.Words.LoadOptions();
    loadOptions.LoadFormat = LoadFormat.Mhtml;
    
    //create an instance of Document and load the MTHML from MemoryStream
    var document = new Aspose.Words.Document(ms, loadOptions);
    
    //create an instance of HtmlSaveOptions and set the SaveFormat to Html
    varsaveOptions = new Aspose.Words.Saving.PdfSaveOptions();
    
    //save the document to Html file
    document.Save("About Aspose.pdf", saveOptions);

    [VB.NET]

    Code:
    Dim mailMsg As MailMessage = MailMessage.Load("About Aspose-1.msg")
    
    Dim ms As New MemoryStream()
    
    'Save as MHTML
    mailMsg.Save(ms, MailMessageSaveType.MHtmlFromat)
    
    'create an instance of LoadOptions and set the LoadFormat to Mhtml
    Dim loadOptions = New Aspose.Words.LoadOptions()
    loadOptions.LoadFormat = LoadFormat.Mhtml
    
    'create an instance of Document and load the MTHML from MemoryStream
    Dim document = New Aspose.Words.Document(ms, loadOptions)
    
    'create an instance of HtmlSaveOptions and set the SaveFormat to Html
    Dim saveOptions = New Aspose.Words.Saving.PdfSaveOptions()
    
    'save the document to Html file
    document.Save("About Aspose.pdf", saveOptions);

  2. #2
    Join Date
    Sep 2014
    Posts
    1

    Re: Convert Microsoft Outlook MSG Email Message to PDF File

    Total Mail Converter will help you to convert MSG to PDF in batches, hundreds of thousands of them at a time. When batch processing, it's crucial to have flexible settings. Total Mail Converter provides everything to get the output PDF files the way you need.

    For example, it will give descriptive names to output files and attachments. This way you will always know which attachment refers to which email.

    Or it can embed attachments into the final PDF. Then the header of the PDF will contain the filename of the attachment. In a PDF viewer this is a clickable link that will open the attachment in its associated program.

    Some people prefer to combine several MSG files into one multi-page PDF. Total Mail Converter can do that, just tick the appropriate checkbox in the wizard of the program.

    Need to sign PDF files? Just locate your PFX file and the program will add the digital signature to the converted emails. Both PDF and PDF/A formats are supported.


    Download the free trial version and convert MSG to PDF for 30 days. Quite enough time to see how it works!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center