Convert MSG to XPS via C#
Convert MSG to XPS without Microsoft® Outlook® or Thunderbird® installed.
Experience high-speed performance in email processing with Aspose.Email for .NET! It is a C# API that provides developers with a robust set of tools for handling email files without Outlook or Thunderbird installation, including the capability to convert between various formats. Among these capabilities, converting from MSG (Outlook Email Message) to XPS (XML Paper Specification) files is a feature that stands out, as it serves to protect the integrity and layout of the original email message while facilitating easy sharing and viewing without the need for the native application that created the MSG file.
MSG files are created by Microsoft Outlook to store email messages, contacts, appointments, and other data, while XPS (XML Paper Specification) files are similar to PDFs and preserve document fidelity, ensuring that the file can be viewed and printed as it was originally designed, regardless of the system or software being used. This conversion is necessary when you need a snapshot of the email content that cannot be altered and is widely accessible. The features of XPS files include a fixed layout, support for digital signatures, and the ability to retain the structure of the original document, including text, images, and formatting. This makes the XPS format suitable for legal documents, archival purposes, and sharing files with individuals who may not have Outlook or a compatible email client.
The email-to-storage-file conversion process with Aspose.Email for .NET is straightforward. The library presents an easy-to-use object model. Converting emails typically requires only a few lines of code, abstracting away the underlying file format parsing, MIME handling, encoding issues, etc. When you use Aspose.Email for .NET, you do not need to manually process any of these aspects. Instead, you write only the high-level code required to perform the task.
Enhance your performance with a comprehensive and easy-to-use API that simplifies complex email management tasks, such as sending, receiving, and processing emails, as well as converting between various email formats. This allows developers to efficiently integrate email functionality into their applications without delving into low-level details, thus significantly reducing development time and effort.
To leverage the power of the .NET API, perform 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
Steps to Convert MSG to XPS via C#
.NET programmers can easily load & convert MSG files to XPS in just a few lines of code.
- Load an MSG file into a MapiMessage object.
- Create an instance of MailPrinter.
- Configure printer to display message headers and body.
- Set the units for page layout to centimeters.
- Print the loaded MSG email into an XPS file using the specified settings.
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 MSG to XPS C# Conversion
var msg = MapiMessage.Load("message.msg");
// 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;
// Print the email to an XPS file
printer.Print(msg, "message.xps", Printing.PrintFormat.XPS);
Free App to Convert MSG to XPS
Other Supported Conversions
You can also convert MSG into many other file formats including few listed below.