MapiAttachment

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.

from aspose.email_foss import msg

message = msg.MapiMessage.create("Report", "See attached.")
message.add_attachment("report.pdf", b"%PDF-content", mime_type="application/pdf")
for att in message.iter_attachments_info():
    print(att.filename, att.is_embedded_message)
message.save("with-attachment.msg")

Class Methods

SignatureDescription
from_bytes(filename, data, mime_type=None, content_id=None) -> MapiAttachmentCreate an attachment from raw bytes.
from_embedded_message(message, filename=None, mime_type=None) -> MapiAttachmentCreate an attachment wrapping an embedded MapiMessage.

Properties

NameTypeAccessDescription
storage_namestr | Noneread-onlyCFB storage name for this attachment.
is_embedded_messageboolread-onlyTrue if this attachment contains an embedded MSG.
is_storage_attachmentboolread-onlyTrue if the attachment uses a custom CFB storage.
embedded_storage_namestr | Noneread-onlyStorage name of the embedded message, if any.

Key Fields

NameTypeDescription
filenamestr | NoneAttachment file name.
databytesRaw attachment bytes.
mime_typestr | NoneMIME content type.
content_idstr | NoneContent-ID for inline attachments.
attach_methodintMAPI attach method code.
embedded_messageMapiMessage | NoneThe embedded message, if is_embedded_message is True.
propertiesMapiPropertyCollectionFull MAPI property bag for this attachment.

Methods

SignatureDescription
set_property(property_id, property_type_or_value, value=..., flags=...) -> MapiPropertySet or replace a MAPI property on this attachment.

See Also