MsgDocument

Overview

MsgDocument is the mutable in-memory model of an Outlook MSG file at the storage level. It is one abstraction layer below MapiMessage: instead of named properties and typed recipients, you work directly with MsgStorage nodes and raw property streams. Load it with from_file() or from_reader(), manipulate the root storage tree, and write it back with MsgWriter. Convert up to a MapiMessage via MapiMessage.from_msg_document() when higher-level access is needed.

from aspose.email_foss.msg import MsgDocument, MsgWriter

doc = MsgDocument.from_file("input.msg")
print(doc.root.name)
MsgWriter.write_file(doc, "output.msg")

Class Methods

SignatureDescription
from_reader(reader) -> MsgDocumentBuild an MsgDocument from an open MsgReader.
from_file(path, strict=False) -> MsgDocumentOpen a .msg file and parse it into an MsgDocument.

Key Fields

NameTypeDescription
rootMsgStorageRoot storage node of the MSG hierarchy.
major_versionintCFB major version from the file header.
minor_versionintCFB minor version from the file header.
transaction_signature_numberintMSG transaction signature.
strictboolWhether the document was loaded in strict mode.

Methods

SignatureDescription
to_cfb_document() -> CFBDocumentConvert this MsgDocument to a low-level CFBDocument for direct CFB manipulation.
build_storage(entry, role) -> MsgStorageWrap a DirectoryEntry as a typed MsgStorage node with the given role.

See Also