Overview
MapiAttachment represents a file or embedded-message attachment in a MAPI .msg email. Create attachments using the static factory methods FromBytes or FromStream, then add them to a MapiMessage via AddAttachment. Read the attachment content via LoadData or OpenRead. The Properties collection exposes low-level MAPI property streams for the attachment storage.
Methods
| Signature | Description |
|---|
FromBytes(filename: string, data: byte[], mimeType: string?, contentId: string?) | Creates a MapiAttachment from a byte array with optional MIME type and Content-ID. |
FromStream(filename: string, stream: Stream, mimeType: string?, contentId: string?) | Creates a MapiAttachment by reading all bytes from stream. |
LoadData(stream: Stream) | Loads attachment binary data from stream into Data. |
OpenRead() | Returns a Stream positioned at the start of the attachment data for sequential reading. |
Properties
| Name | Type | Access | Description |
|---|
Filename | string? | Read | Original filename of the attached file, or null if not set. |
Data | byte[] | Read | Raw binary content of the attachment. |
MimeType | string? | Read | MIME content-type string (e.g. application/pdf), or null if not specified. |
ContentId | string? | Read | Content-ID header value for inline MIME attachments, or null if not set. |
EmbeddedMessage | MapiMessage? | Read | The embedded MapiMessage when IsEmbeddedMessage is true; otherwise null. |
Properties | MapiPropertyCollection | Read | Low-level MAPI property collection for this attachment’s storage. |
IsEmbeddedMessage | bool | Read | The embedded MapiMessage when IsEmbeddedMessage is true; otherwise null. |
IsStorageAttachment | bool | Read | True if the attachment is stored as a sub-storage in the CFB document rather than a stream. |
See Also