MapiAttachment

MapiAttachment

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

SignatureDescription
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

NameTypeAccessDescription
Filenamestring?ReadOriginal filename of the attached file, or null if not set.
Databyte[]ReadRaw binary content of the attachment.
MimeTypestring?ReadMIME content-type string (e.g. application/pdf), or null if not specified.
ContentIdstring?ReadContent-ID header value for inline MIME attachments, or null if not set.
EmbeddedMessageMapiMessage?ReadThe embedded MapiMessage when IsEmbeddedMessage is true; otherwise null.
PropertiesMapiPropertyCollectionReadLow-level MAPI property collection for this attachment’s storage.
IsEmbeddedMessageboolReadThe embedded MapiMessage when IsEmbeddedMessage is true; otherwise null.
IsStorageAttachmentboolReadTrue if the attachment is stored as a sub-storage in the CFB document rather than a stream.

See Also