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
| Requirement | Detail |
|---|---|
| .NET | 8.0 or later |
| Package manager | NuGet (dotnet CLI or Visual Studio) |
| OS | Windows, macOS, or Linux |
| Dependencies | None — pure managed C# |
Installation
Install from NuGet:
dotnet add package Aspose.Email.FossVerify in a minimal console app:
using Aspose.Email.Foss.Msg;
var message = MapiMessage.Create("Test", "Hello");
Console.WriteLine($"Subject: {message.Subject}");
// Output: Subject: TestSee the Installation Guide for project setup details.
What You Can Do
Once installed you can immediately:
- Read MSG files with
MapiMessage.FromStream()orMapiMessage.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 withmessage.Save() - Convert between MSG and EML (MIME/RFC 5322) with
LoadFromEml()andSaveToEml() - Inspect the underlying CFB binary container with
CfbReader— traverse storages and streams, resolve paths, read raw bytes - Write CFB documents with
CfbWriterfor 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
- Installation Guide: Project setup and NuGet installation details
- Developer Guide: MSG operations, attachments, MAPI properties, and CFB structure
- Features: Deep-dive into every feature with C# examples