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.
streamslist[MsgStream]Direct child streams belonging to this storage.
storageslist[MsgStorage]Direct child storages belonging to this storage.

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