Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

Read, Write, and Convert Email and Outlook Files

Edit on GitHub

OfficeIMO.Email reads and writes EML, MSG, OFT, TNEF, PST, OST, OLM, mbox, calendar and contact files in .NET, with no Outlook installed.

Packages
Works with
  • .NET
  • PowerShell Install-Module PSWriteOffice
  • CLI dotnet tool install --global OfficeIMO.Tool
Target frameworks
netstandard2.0, net10.0, net472
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 toPage
Read or convert EML, MSG, OFT, TNEF, or winmail.datRead and Convert Email Messages
Read PST, OST, OLM, mbox, EMLX, Apple Mail, or Maildir, or convert a store to PSTRead and Convert PST, OST, and Mailbox Stores
Read or update ICS, vCalendar, vCard, or Outlook recurrenceRead and Edit Calendars, Contacts, and Outlook Items
Limit untrusted input, read diagnostics, or verify a migrationRead 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

FamilyFormats and operations
MessagesEML/MIME, MSG, OFT, TNEF, attachments, embedded messages, inline resources, HTML, plain text, and RTF bodies
Outlook itemsMessages, appointments, contacts, tasks, journals, sticky notes, meeting items, and distribution lists
Storesmboxo, mboxrd, PST, OST, OLM, EMLX, Apple Mail, Maildir, and mailbox directories
Calendars and contactsICS, vCalendar, vCard 2.1/3.0/4.0, recurrence, time zones, and reminders
Address booksOutlook Offline Address Book discovery, v4 entry decoding, search, and offline identity resolution
VerificationStructured diagnostics, bounded I/O, conversion analysis, semantic fingerprints, and comparison reports

Example source