HTML JPG EMAIL XML OST
  Product Family
XPS

Convert OST to XPS via C#

Convert OST to XPS without Microsoft® Outlook® or Thunderbird® installed.

For C# developers looking for a reliable and efficient solution to convert OST to XPS, Aspose.Email for .NET offers a comprehensive and user-friendly file conversion API. The API is a part of a progressive and versatile library providing a straightforward and intuitive approach to handle various email processing tasks, such as creating and managing email messages, attachments, extracting email metadata, interacting with email servers via various protocols, as well as converting between email formats without Outlook or Thunderbird dependencies.

Converting OST to XPS streamlines exporting and archiving of emails and attachments from Outlook for developers, with our intuitive API supporting the process. This allows for automated and simplified email data transfer, facilitating a smooth transition between email clients without complex manual conversion tasks. Consequently, developers can optimize time and resources, enhancing the efficiency of their email processes.

The code sample below demonstrates how to convert a OST file to XPS format in a few lines of code with high quality results. The process includes some simple and straightforward steps like loading email data, processing it and saving it in the desired format. This makes the API an outstanding tool for automating file conversion tasks in C# applications.

Convert your OST files to XPS format right now. Start by including the Aspose.Email namespace in your C# project. You can do it by performing one of the following actions:

  • Open NuGet package manager, search for Aspose.Email and install it on your device.

  • Use the following command from the Package Manager Console:


PM> Install-Package Aspose.Email

For further information you can consult our documentation or support.

Steps to Convert OST to XPS via C#

.NET programmers can easily load & convert OST files to XPS in just a few lines of code.

  1. Open the OST file “storage.ost”.
  2. Create the output directory if it doesn’t exist.
  3. Access the “Inbox” folder in the OST file.
  4. Iterate through each message in the “Inbox” folder.
  5. Print each message to an XPS file using MailPrinter and save in the output directory.

System Requirements

Before running the .NET conversion source code, make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with .NET Framework, .NET Core, and PHP, VBScript, Delphi, C++ via COM Interop.
  • Development environment like Microsoft Visual Studio.
  • Aspose.EMAIL for .NET DLL referenced in your project.
 

This sample code shows OST to XPS C# Conversion

using (var ost = PersonalStorage.FromFile("storage.ost"))
{
    // Ensure the output directory exists
    Directory.CreateDirectory(outputDirectory);

    var inboxFolder = ost.GetPredefinedFolder(StandardIpmFolder.Inbox);

    // Iterate through mbox messages and save them as .xps files
    int count = 1;

    foreach (var msg in inboxFolder.EnumerateMapiMessages())
    {
        // Instantiate an instance of MailPrinter
        var printer = new Printing.MailPrinter();

        // Set MessageFormattingFlags to MailInfo to display the message headers and body
        printer.FormattingFlags = Printing.MessageFormattingFlags.MailInfo;

        // Set page layout for printing
        printer.PageUnit = Printing.PrinterUnit.Cm;
        
        var dstXPS = Path.Combine(outputDirectory, $"Message{count}.xps");
        
        // Print the email to an XPS file
        printer.Print(msg, dstXPS, Printing.PrintFormat.XPS);

        count++;
    }
}
 
  • Free App to Convert OST to XPS

    Other Supported Conversions

    You can also convert OST into many other file formats including few listed below.

    OST TO EML (Outlook Email Messages)
    OST TO EMLX (Apple EMLX Format)
    OST TO HTML (Hyper Text Markup Language)
    OST TO ICS (iCalendar)
    OST TO MBOX (Electronic Mail Messages)
    OST TO MHTML (Web Page Archive Format)
    OST TO MSG (Outlook & Exchange Format)
    OST TO OFT (Outlook Email Templates)
    OST TO PST (Personal Storage Table)
    OST TO VCF (Virtual Card Format)