Getting Started

Getting Started with Aspose.Email FOSS for .NET

Welcome to Aspose.Email FOSS for .NET, a free, MIT-licensed C# library for reading, creating, and writing Outlook MSG files, Compound File Binary (CFB) containers, and EML messages. This guide takes you from a fresh .NET project to working with MSG files in minutes.


Prerequisites

RequirementDetail
.NET8.0 or later
Package managerNuGet (dotnet CLI or Visual Studio)
OSWindows, macOS, or Linux
DependenciesNone — pure managed C#

Installation

Install from NuGet:

dotnet add package Aspose.Email.Foss

Verify in a minimal console app:

using Aspose.Email.Foss.Msg;

var message = MapiMessage.Create("Test", "Hello");
Console.WriteLine($"Subject: {message.Subject}");
// Output: Subject: Test

See the Installation Guide for project setup details.


What You Can Do

Once installed you can immediately:

  • Read MSG files with MapiMessage.FromStream() or MapiMessage.FromFile() — access subject, body, HTML body, sender, recipients, and attachments
  • Create MSG messages from scratch with MapiMessage.Create() — set all fields, add recipients and attachments, then serialize with message.Save()
  • Convert between MSG and EML (MIME/RFC 5322) with LoadFromEml() and SaveToEml()
  • Inspect the underlying CFB binary container with CfbReader — traverse storages and streams, resolve paths, read raw bytes
  • Write CFB documents with CfbWriter for forensic inspection or format construction
  • Handle attachments — add file, stream, or embedded MSG attachments with full metadata

Quick Start

Read an MSG file and print its subject and recipients:

using System.IO;
using Aspose.Email.Foss.Msg;

using var stream = File.OpenRead("sample.msg");
var message = MapiMessage.FromStream(stream);

Console.WriteLine($"Subject: {message.Subject}");
Console.WriteLine($"From: {message.SenderEmailAddress}");

foreach (var recipient in message.Recipients)
    Console.WriteLine($"To: {recipient.EmailAddress}");

foreach (var attachment in message.Attachments)
    Console.WriteLine($"Attachment: {attachment.Filename} ({attachment.MimeType})");

Next Steps

See Also

 English