Class OlmStorage
Contents
[
Hide
]OlmStorage class
Represents an Outlook for Mac (.OLM) storage file and provides functionality to access and manipulate the data within the file such as emails, contacts, calendars, tasks, and notes.
public class OlmStorage : IDisposable
Constructors
Name | Description |
---|---|
OlmStorage(Stream) | Initializes a new instance of the OlmStorage class. |
OlmStorage(string) | Initializes a new instance of the OlmStorage class. |
OlmStorage(TraversalExceptionsCallback) | Initializes a new instance of the OlmStorage class. Allows setting a callback method for handling exceptions that occur during OLM storage traversal. |
Properties
Name | Description |
---|---|
FolderHierarchy { get; } | Gets the folder hierarchy. |
Methods
Name | Description |
---|---|
static FromFile(string) | Load OLM storage from file. |
static FromStream(Stream) | Load OLM from stream. |
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
EnumerateMessages(OlmFolder) | Exposes the enumerator, which supports an iteration of messages in folder. |
ExtractMapiMessage(OlmMessageInfo) | Get the message from OLM storage. |
ExtractMapiMessage(string) | Get the message from OLM. |
GetCategories() | Gets the supported item categories. |
GetFolder(string, bool) | Gets the folder by name. |
GetFolders() | Gets collection of folders. |
GetTotalItemsCount() | Gets the total items count. Returns the total number of message items contained in the OLM. |
Load(Stream) | Load OLM storage from stream. This method is used when a OlmStorage object is created using constructor with the TraversalExceptionsCallback parameter. |
Load(string) | Load OLM storage from file. This method is used when a OlmStorage object is created using constructor with the TraversalExceptionsCallback parameter. |
Remarks
The OlmStorage class allows users to read from and interact with the contents of .OLM files typically used by Microsoft Outlook for Mac. This class handles the various data types stored within an .OLM file by providing methods to enumerate and extract information.
Examples
The following code shows how to access and retrieve information from an Outlook for Mac data file (.olm file).
[C#]
using (var olm = OlmStorage.FromFile("storage.olm"))
{
// Retrieve the total number of items in the OLM storage.
var totalItemsCount = olm.GetTotalItemsCount();
Console.WriteLine($"Total items count: {totalItemsCount}");
// Iterate through each folder in the OLM storage.
foreach (var olmFolder in olm.GetFolders())
{
// Print the name of the currently iterated folder and the count of messages it contains.
Console.WriteLine($"Folder: {olmFolder.Name}");
Console.WriteLine($"Total items: {olmFolder.MessageCount}");
// Iterate through each message in the current folder.
foreach (var messageInfo in olmFolder.EnumerateMessages())
{
// Print the subject of the current message to the console.
Console.WriteLine($"Subject: {messageInfo.Subject}");
// Extract the full message object from the OLM storage.
var msg = olm.ExtractMapiMessage(messageInfo);
// Save the extracted message as a .msg file.
msg.Save($"{msg.Subject}.msg");
}
}
}
[Visual Basic]
Using olm As var = OlmStorage.FromFile("storage.olm")
' Retrieve the total number of items in the OLM storage and store the count in totalItemsCount.
Dim totalItemsCount As Integer = olm.GetTotalItemsCount()
' Print the total number of items in the OLM storage to the console.
Console.WriteLine($"Total items count: {totalItemsCount}")
' Iterate through each folder in the OLM storage.
For Each olmFolder In olm.GetFolders()
' Print the name of the currently iterated folder and the count of messages it contains.
Console.WriteLine($"Folder: {olmFolder.Name}")
Console.WriteLine($"Total items: {olmFolder.MessageCount}")
' Iterate through each message in the current folder.
For Each messageInfo In olmFolder.EnumerateMessages()
' Print the subject of the current message to the console.
Console.WriteLine($"Subject: {messageInfo.Subject}")
' Extract the full message object from the OLM storage using the information from messageInfo.
Dim msg As var = olm.ExtractMapiMessage(messageInfo)
' Save the extracted message as a .msg file on disk using its subject as the filename.
' Note: Message subject may need sanitization to be used as a valid filename.
msg.Save($"{msg.Subject}.msg")
Next
Next
End Using
See Also
- namespace Aspose.Email.Storage.Olm
- assembly Aspose.Email