Created
December 16, 2022 18:58
Read OLM files Without Outlook in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var olm = OlmStorage.FromFile(fileName)) | |
{ | |
var folder = olm.GetFolder("Inbox", true); | |
if (folder.HasMessages) | |
{ | |
Console.WriteLine($"Message count: {folder.MessageCount}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var olm = OlmStorage.FromFile(fileName)) | |
{ | |
var folder = olm.GetFolder("Inbox", true); | |
foreach (var messageInfo in folder.EnumerateMessages()) | |
{ | |
if (messageInfo.Date == DateTime.Today) | |
{ | |
// Extracts today's messages form Inbox | |
var msg = olm.ExtractMapiMessage(messageInfo); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var olm = new OlmStorage(fileName)) | |
{ | |
PrintAllFolders(olm.FolderHierarchy, string.Empty); | |
} | |
private void PrintAllFolders(List<OlmFolder> folderHierarchy, string indent) | |
{ | |
foreach (var folder in folderHierarchy) | |
{ | |
Console.WriteLine($"{indent}{folder.Name}"); | |
PrintAllFolders(folder.SubFolders, indent+"-"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var olm = OlmStorage.FromFile(fileName)) | |
{ | |
// get inbox folder by name | |
OlmFolder folder = olm.GetFolder("Inbox", true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var olm = OlmStorage.FromFile(fileName)) | |
{ | |
var folders = olm.GetFolders(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var olm = OlmStorage.FromFile(fileName)) | |
{ | |
var folder = olm.GetFolder("Inbox", true); | |
foreach (var msg in folder.EnumerateMapiMessages()) | |
{ | |
// save message in MSG format | |
msg.Save($"{msg.Subject}.msg"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var olm = OlmStorage.FromFile(fileName)) | |
{ | |
var folder = olm.GetFolder("Inbox", true); | |
foreach (var messageInfo in folder.EnumerateMessages()) | |
{ | |
Console.WriteLine(messageInfo.Subject); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileName = "MyStorage.olm"; | |
var olm = new OlmStorage(fileName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileName = "MyStorage.olm"; | |
var olm = OlmStorage.FromFile(fileName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment