MsgStorage

Overview

MsgStorage represents a CFB storage entry within an MsgDocument tree. Each storage may contain any number of named child streams (MsgStream) and nested child storages (MsgStorage), mirroring the hierarchical structure of the Compound File Binary format. Instances are obtained from MsgDocument.root or from add_storage() / find_storage() calls on a parent storage.

from aspose.email_foss.msg import MsgDocument

doc = MsgDocument.from_file("message.msg")
root = doc.root
for stream in root.iter_streams():
    print(f"stream: {stream.name}, {len(stream.data)} bytes")
for storage in root.iter_storages():
    print(f"storage: {storage.name}")

Properties

PropertyTypeDescription
namestrName of this storage entry as it appears in the CFB directory.
rolestrSemantic role label assigned during parsing (e.g., "root", "recipient", "attachment").
clsidbytes16-byte CLSID associated with this storage, or 16 zero bytes if absent.
state_bitsintUser-defined state bits stored in the CFB directory entry.
creation_timeintCreation timestamp as a 64-bit Windows FILETIME value.
modified_timeintLast-modified timestamp as a 64-bit Windows FILETIME value.
streamslist[MsgStream]Direct child streams belonging to this storage.
storageslist[MsgStorage]Direct child storages belonging to this storage.
property_header_kindstr | NoneIdentifies whether this storage has a top-level or sub-object property stream header, or None if no property stream was found.
property_stream_headerPropertyStreamHeaderTopLevel | PropertyStreamHeaderSubobject | NoneParsed property stream header for this storage, or None if absent.
fixed_length_propertiestuple[PropertyEntryFixedLength, ...]Fixed-length property entries parsed from the property stream; empty if no property stream is present.
property_stream_parse_errorstr | NoneError message from property stream parsing, or None if parsing succeeded.

Methods

add_stream(stream) -> MsgStream

Appends stream to self.streams and returns the same MsgStream instance. Raises ValueError if a stream with the same name already exists in this storage.

ParameterTypeDescription
streamMsgStreamThe stream object to attach.

Returns: The MsgStream that was added.


add_storage(storage) -> MsgStorage

Appends storage to self.storages and returns the same MsgStorage instance. Raises ValueError if a child storage with the same name already exists.

ParameterTypeDescription
storageMsgStorageThe child storage object to attach.

Returns: The MsgStorage that was added.


iter_streams() -> Iterator[MsgStream]

Yields each MsgStream in self.streams in order.


iter_storages() -> Iterator[MsgStorage]

Yields each MsgStorage in self.storages in order.


find_stream(name) -> MsgStream | None

Returns the first child stream whose name matches the given string (case-sensitive), or None if not found.

ParameterTypeDescription
namestrExact name of the stream to locate.

find_storage(name) -> MsgStorage | None

Returns the first child storage whose name matches the given string (case-sensitive), or None if not found.

ParameterTypeDescription
namestrExact name of the storage to locate.

See Also