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
| Property | Type | Description |
|---|---|---|
name | str | Name of this storage entry as it appears in the CFB directory. |
role | str | Semantic role label assigned during parsing (e.g., "root", "recipient", "attachment"). |
clsid | bytes | 16-byte CLSID associated with this storage, or 16 zero bytes if absent. |
state_bits | int | User-defined state bits stored in the CFB directory entry. |
streams | list[MsgStream] | Direct child streams belonging to this storage. |
storages | list[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.
| Parameter | Type | Description |
|---|---|---|
stream | MsgStream | The 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.
| Parameter | Type | Description |
|---|---|---|
storage | MsgStorage | The 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.
| Parameter | Type | Description |
|---|---|---|
name | str | Exact 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.
| Parameter | Type | Description |
|---|---|---|
name | str | Exact name of the storage to locate. |