Read, Write, and Convert Email and Outlook Files
Edit on GitHubOfficeIMO.Email reads and writes EML, MSG, OFT, TNEF, PST, OST, OLM, mbox, calendar and contact files in .NET, with no Outlook installed.
- Packages
- OfficeIMO.Email
dotnet add package OfficeIMO.Email
- OfficeIMO.Email
- Works with
- .NET
- PowerShell
Install-Module PSWriteOffice - CLI
dotnet tool install --global OfficeIMO.Tool
- Target frameworks
- netstandard2.0, net10.0, net472
- APIs
- Commands
- Verified
- Examples compiled against the source on
OfficeIMO.Email works with saved email and Outlook data without Outlook, COM, or third-party message parsers. Use EmailDocument for single messages (EML/MIME, MSG, OFT, TNEF), EmailStoreSession for mailbox stores, and IcsDocument or VCardDocument for calendars and contacts.
| You want to | Page |
|---|---|
Read or convert EML, MSG, OFT, TNEF, or winmail.dat | Read and Convert Email Messages |
| Read PST, OST, OLM, mbox, EMLX, Apple Mail, or Maildir, or convert a store to PST | Read and Convert PST, OST, and Mailbox Stores |
| Read or update ICS, vCalendar, vCard, or Outlook recurrence | Read and Edit Calendars, Contacts, and Outlook Items |
| Limit untrusted input, read diagnostics, or verify a migration | Read Untrusted Email Safely and Verify Conversions |
For text extraction across many formats rather than format-specific editing, use the Reader.
Convert one message
Save picks the output format from the extension. A conversion that would lose protected content, recurrence data, or another known semantic is blocked unless you accept the loss explicitly.
C#
using OfficeIMO.Email;
EmailDocument message = EmailDocument.Load("message.msg");
Console.WriteLine(message.Subject);
Console.WriteLine(message.Body.Text);
var options = new EmailWriterOptions(EmailConversionLossPolicy.Warn);
EmailWriteResult converted = message.Save("message.eml", options);
foreach (EmailDiagnostic diagnostic in converted.Diagnostics) {
Console.WriteLine(diagnostic.Message);
}
PowerShell
$options = New-OfficeEmailWriterOptions -AllowLoss
$converted = Open-OfficeEmail -Path .\message.msg |
Save-OfficeEmail -Path .\message.eml -Options $options -PassThru
$converted.Diagnostics
Use the C# and PowerShell loss options after reviewing what EML cannot carry.
CLI
officeimo convert message.msg message.eml
The CLI reports Outlook-specific metadata that EML cannot carry. Add --require-no-loss to leave the destination unchanged when that omission is detected.
What the package covers
| Family | Formats and operations |
|---|---|
| Messages | EML/MIME, MSG, OFT, TNEF, attachments, embedded messages, inline resources, HTML, plain text, and RTF bodies |
| Outlook items | Messages, appointments, contacts, tasks, journals, sticky notes, meeting items, and distribution lists |
| Stores | mboxo, mboxrd, PST, OST, OLM, EMLX, Apple Mail, Maildir, and mailbox directories |
| Calendars and contacts | ICS, vCalendar, vCard 2.1/3.0/4.0, recurrence, time zones, and reminders |
| Address books | Outlook Offline Address Book discovery, v4 entry decoding, search, and offline identity resolution |
| Verification | Structured diagnostics, bounded I/O, conversion analysis, semantic fingerprints, and comparison reports |