Overview
MapiAttachment represents a single attachment on a MapiMessage. It can hold raw file bytes or an embedded MapiMessage. Instances are typically obtained from MapiMessage.add_attachment(), MapiMessage.add_embedded_message_attachment(), or MapiMessage.iter_attachments_info(). You can also construct standalone instances using the class methods and later add them to a message.
Class Methods
| Signature | Description |
|---|
from_bytes(filename, data, mime_type=None, content_id=None) -> MapiAttachment | Create an attachment from raw bytes. |
from_embedded_message(message, filename=None, mime_type=None) -> MapiAttachment | Create an attachment wrapping an embedded MapiMessage. |
Properties
| Name | Type | Access | Description |
|---|
storage_name | str | None | read-only | CFB storage name for this attachment. |
is_embedded_message | bool | read-only | True if this attachment contains an embedded MSG. |
is_storage_attachment | bool | read-only | True if the attachment uses a custom CFB storage. |
embedded_storage_name | str | None | read-only | Storage name of the embedded message, if any. |
Key Fields
| Name | Type | Description |
|---|
filename | str | None | Attachment file name. |
data | bytes | Raw attachment bytes. |
mime_type | str | None | MIME content type. |
content_id | str | None | Content-ID for inline attachments. |
attach_method | int | MAPI attach method code. |
embedded_message | MapiMessage | None | The embedded message, if is_embedded_message is True. |
properties | MapiPropertyCollection | Full MAPI property bag for this attachment. |
Methods
| Signature | Description |
|---|
set_property(property_id, property_type_or_value, value=..., flags=...) -> MapiProperty | Set or replace a MAPI property on this attachment. |
See Also