Microsoft Outlook is available for Windows and Mac Operating systems. Outlook for Mac and Outlook for Windows, store user emails in data files. These data files consist of all emails, contacts, tasks, notes and calendar items. Outlook for Mac keeps mailbox items in OLM file, which isn’t supported by Outlook for Windows. Thus, there is not possible to open an Outlook for Mac (OLM) file in Outlook for Windows. If you want to migrate your mailbox from Outlook for Mac to Outlook for Windows, you must convert the Outlook for Mac OLM file to Outlook PST file format. This article covers how to Convert OLM file to PST file programmatically in C#.

The following topics will be covered in this article:

C# API to convert OLM to PST

To convert OLM to PST, we will use Aspose.Email for .NET. It is an email processing API that lets you manipulate emails and work with file formats of popular email clients such as Thunderbird, Outlook, etc. You can download the API’s DLL or install it from NuGet using the following command.

PM> Install-Package Aspose.Email

Steps to Convert OLM to PST

We can convert an OLM file to PST by following the steps given below:

  • Create a new PST file and open it for writing
  • Open a source OLM file
  • Read each mailbox item from OLM and write it to PST

The following section describes how to transform these steps into C# and convert files from OLM to PST.

Convert OLM to PST programmatically using C#

We can convert OLM to PST programmatically in C# by following the steps given below:

  • Firstly, create an instance of OlmStorage class to open source OLM.
  • Next, create a new PST file using Create method.
  • In addition, we will create a GetContainerClass function which will map the message class to a folder class, so that we can create PST folders with container class that correspond to the message class they contain.
  • Finally, create an AddToPst function that recursively reads each folder and its messages from OLM using EnumerateMapiMessages method and adds them to the PST in the same order using AddSubFolder and AddMessage methods.

The following code sample shows how to convert an OLM to a PST in C#.

Main method:

GetContainerClass function:

AddToPst function:

Get a Free API License

You can use Aspose.Email for .NET without evaluation limitations using a free temporary license.


In this article, you have learned how to convert OLM to PST in C# .NET. Also, you have seen how to read messages from OLM storage and write items to PST storage programmatically. Apart from that, you can visit the documentation to explore other features of Aspose.Email for .NET. In case you would have any questions, you can post to our forum.

See Also