---
Product: Aspose.Email
Platform: net
Page Type: reference
Canonical URL: https://reference.aspose.org/email/net/mapi-message
---

# MapiMessage

## Overview

`MapiMessage` is the primary class for reading and writing `.msg` email files in the Aspose.Email FOSS library. Load an existing message with `FromFile`, `FromStream`, or one of the `LoadFromEml` overloads. Build a new message with `Create`, then call `AddRecipient` and `AddAttachment`. Save back to `.msg` with `Save`, or export to EML with `SaveToEml`. Implements `IDisposable`; use a `using` block to ensure resources are released.

## Methods

| Signature | Description |
|-----------|-------------|
| `Create(subject: string, body: string, unicodeStrings: bool)` | Creates a new `MapiMessage` with the given subject and body, optionally using Unicode strings. |
| `FromFile(path: string, strict: bool)` | Loads a `MapiMessage` from a `.msg` file at `path`; `strict` enables full structural validation. |
| `FromStream(stream: Stream, strict: bool)` | Loads a `MapiMessage` from `stream`; `strict` enables full structural validation. |
| `FromMsgDocument(document: MsgDocument)` | Wraps an already-parsed `MsgDocument` in a `MapiMessage`. |
| `LoadFromEml(path: string)` | Converts an EML file at `path` to a `MapiMessage` via in-memory MIME parsing. |
| `LoadFromEml(stream: Stream)` | Converts an EML file at `path` to a `MapiMessage` via in-memory MIME parsing. |
| `LoadFromEml(data: byte[])` | Converts an EML file at `path` to a `MapiMessage` via in-memory MIME parsing. |
| `Dispose()` | Releases unmanaged resources held by this message. |
| `AddRecipient(emailAddress: string, displayName: string?, recipientType: int)` | Adds a recipient with the given email address, display name, and type (1 = To, 2 = Cc, 3 = Bcc). |
| `AddAttachment(filename: string, data: byte[], mimeType: string?, contentId: string?)` | Attaches a file by name and binary data, optionally specifying MIME type and Content-ID. |
| `AddAttachment(filename: string, stream: Stream, mimeType: string?, contentId: string?)` | Attaches a file by name and binary data, optionally specifying MIME type and Content-ID. |
| `AddEmbeddedMessageAttachment(message: MapiMessage, filename: string?, mimeType: string?)` | Attaches another `MapiMessage` as an embedded-message attachment. |
| `SetProperty(propertyId: ushort, propertyType: ushort, value: object?, flags: uint)` | Sets a raw MAPI property by property ID, type, value, and flags. |
| `GetPropertyValue(propertyId: ushort, propertyType: ushort?, decode: bool)` | Retrieves the value of a MAPI property by ID and optional type; `decode` controls string decoding. |
| `IterPropertyKeys()` | Enumerates the (propertyId, propertyType) key pairs of all stored properties. |
| `IterProperties()` | Enumerates all `MapiProperty` objects stored in this message. |
| `IterAttachmentsInfo()` | Enumerates attachment metadata without loading full attachment data. |
| `ToMsgDocument()` | Converts this `MapiMessage` to a `MsgDocument` suitable for CFB serialization. |
| `Save()` | Saves the message in-place (for messages originally loaded from a file or stream). |
| `Save(path: string)` | Saves the message in-place (for messages originally loaded from a file or stream). |
| `Save(stream: Stream)` | Saves the message in-place (for messages originally loaded from a file or stream). |
| `SaveToEml()` | Saves the message in-place (for messages originally loaded from a file or stream). |
| `SaveToEml(path: string)` | Saves the message in-place (for messages originally loaded from a file or stream). |
| `SaveToEml(stream: Stream)` | Saves the message in-place (for messages originally loaded from a file or stream). |

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `RecipientTypeTo` | `int` | Read | Constant value 1 for To recipients |
| `RecipientTypeCc` | `int` | Read | Constant value 2 for Cc recipients |
| `RecipientTypeBcc` | `int` | Read | Constant value 3 for Bcc recipients |
| `UnicodeStrings` | `bool` | Read | True if string properties are stored as Unicode (PT_UNICODE); false for ANSI (PT_STRING8). |
| `Properties` | `MapiPropertyCollection` | Read | Top-level MAPI property collection for this message. |
| `Recipients` | `IList<MapiRecipient>` | Read | Ordered list of `MapiRecipient` entries for To, Cc, and Bcc addresses. |
| `Attachments` | `IList<MapiAttachment>` | Read | Ordered list of `MapiAttachment` entries. |
| `MajorVersion` | `ushort` | Read | CFB major version from the underlying compound file header. |
| `MinorVersion` | `ushort` | Read | CFB minor version from the underlying compound file header. |
| `TransactionSignatureNumber` | `uint` | Read | CFB transaction signature number from the file header. |
| `ValidationIssues` | `IReadOnlyList<string>` | Read | List of structural validation issues detected when `strict` mode was enabled. |
| `Subject` | `string?` | Read | Message subject string, or `null` if not set. |
| `Body` | `string?` | Read | Plain-text message body, or `null` if not set. |
| `HtmlBody` | `string?` | Read | HTML-formatted message body, or `null` if not set. |
| `MessageClass` | `string?` | Read | MAPI message class string (e.g. `IPM.Note`), or `null` if not set. |
| `SenderName` | `string?` | Read | Sender display name, or `null` if not set. |
| `SenderEmailAddress` | `string?` | Read | Sender SMTP email address, or `null` if not set. |
| `SenderAddressType` | `string?` | Read | Sender address type string (e.g. `SMTP`), or `null` if not set. |
| `InternetMessageId` | `string?` | Read | RFC 2822 Message-ID value, or `null` if not set. |
| `MessageDeliveryTime` | `DateTime?` | Read | Delivery timestamp as `DateTime?`, or `null` if not set. |

## See Also
- [Aspose.Email for .NET — Enterprise API Reference](https://reference.aspose.com/email/net/)