---
Product: Aspose.Email
Platform: net
Page Type: docs
Canonical URL: https://docs.aspose.org/email/net/getting-started/quickstart
---

# Quickstart

Three working C# examples to get started with Aspose.Email FOSS for .NET — read an MSG file, create and save a message, and convert between EML and MSG.

## Overview

This page contains three self-contained examples you can copy into a .NET 8 console project
and run immediately. Each example covers a core workflow of the library.

### Prerequisites

```bash
dotnet new console -n EmailDemo
cd EmailDemo
dotnet add package Aspose.Email.Foss
```

---

### Example 1 — Read an MSG File

Open an Outlook `.msg` file and print the subject, sender, recipients, and attachments.

```csharp
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.SenderName} <{message.SenderEmailAddress}>");

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

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

---

### Example 2 — Create and Save a Message

Build a complete email with sender, recipients, and an attachment, then write it to an MSG file.

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

var message = MapiMessage.Create("Quarterly Update", "Please see the attached report.");
message.SenderName = "Alice";
message.SenderEmailAddress = "alice@example.com";

message.AddRecipient("bob@example.com", "Bob");
message.AddRecipient("carol@example.com", "Carol", MapiMessage.RecipientTypeCc);

message.AddAttachment("report.pdf", File.ReadAllBytes("report.pdf"), "application/pdf");

message.Save("quarterly-update.msg");
```

Verify the result by reading it back:

```csharp
using var msg = MapiMessage.FromFile("quarterly-update.msg");
Console.WriteLine(msg.Subject);           // Quarterly Update
Console.WriteLine(msg.Attachments.Count); // 1
```

---

### Example 3 — Convert Between EML and MSG

Load a standard `.eml` file (RFC 5322 / MIME) and save it as Outlook MSG, then convert back.

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

// EML → MSG
using var emlInput = File.OpenRead("incoming.eml");
var message = MapiMessage.LoadFromEml(emlInput);
message.Save("incoming.msg");

// MSG → EML (round-trip)
message.SaveToEml("roundtrip.eml");
```

Subject, body, HTML body, sender, recipients, and attachments are all preserved through
the EML → MSG → EML round-trip.

---

### Next Steps

- **[Installation Guide](../installation/)** — NuGet setup and project configuration
- **[Features](../../developer-guide/features/)** — Full feature reference with examples
- **[Developer Guide](../../developer-guide/)** — MSG operations, MAPI properties, CFB containers

## See Also

- [Aspose.Email for .NET — Enterprise Documentation](https://docs.aspose.com/email/net/)