---
Product: Aspose.Email
Platform: python
Page Type: reference
Canonical URL: https://reference.aspose.org/email/python/mapimessage
---

# MapiMessage

## Overview

`MapiMessage` is a class in Aspose.Email FOSS for Python.

Mutable high-level MSG object with MSG and EmailMessage conversion support.

This class provides 22 methods for working with MapiMessage objects in Python programs.
Available methods include: `add_attachment`, `add_embedded_message_attachment`, `add_recipient`, `close`, `create`, `from_email_message`, `from_file`, `from_msg_document`, `get_named_property`, `get_property`, `get_property_value`, `iter_attachments_info`, and 10 additional methods.
All public members are accessible to any Python application after installing the Aspose.Email FOSS for Python package.
Properties: `attachments`, `body`, `body_html`, `declared_attachment_count`, `declared_next_attachment_id`, `declared_next_recipient_id`, and 19 more.

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `msg_reader` | `MsgReader` | Read | Gets the msg reader. |
| `validation_issues` | `tuple[str, ...]` | Read | Gets the validation issues. |
| `subject` | `str \| None` | Read/Write | Gets or sets the subject. |
| `body` | `str \| None` | Read/Write | Gets or sets the body. |
| `message_class` | `str \| None` | Read/Write | Gets or sets the message class. |
| `body_html` | `str \| None` | Read/Write | Gets or sets the body html. |
| `unicode_strings` | `bool` | Read/Write | Gets or sets the unicode strings. |
| `properties` | `MapiPropertyCollection` | Read/Write | Gets or sets the properties. |
| `recipients` | `list[MapiRecipient]` | Read/Write | Gets or sets the recipients. |
| `attachments` | `list[MapiAttachment]` | Read/Write | Gets or sets the attachments. |
| `extra_streams` | `list[MsgStream]` | Read/Write | Gets or sets the extra streams. |
| `extra_storages` | `list[MsgStorage]` | Read/Write | Gets or sets the extra storages. |
| `nameid_mapping` | `_NamedPropertyMapping` | Read/Write | Gets or sets the nameid mapping. |
| `major_version` | `int` | Read/Write | Gets or sets the major version. |
| `minor_version` | `int` | Read/Write | Gets or sets the minor version. |
| `transaction_signature_number` | `int` | Read/Write | Gets or sets the transaction signature number. |
| `header_reserved_0` | `bytes` | Read/Write | Gets or sets the header reserved 0. |
| `header_reserved_1` | `bytes` | Read/Write | Gets or sets the header reserved 1. |
| `emit_store_support_mask` | `bool` | Read/Write | Gets or sets the emit store support mask. |
| `emit_compatibility_defaults` | `bool` | Read/Write | Gets or sets the emit compatibility defaults. |
| `preserve_declared_header_counts` | `bool` | Read/Write | Gets or sets the preserve declared header counts. |
| `declared_next_recipient_id` | `int \| None` | Read/Write | Gets or sets the declared next recipient id. |
| `declared_next_attachment_id` | `int \| None` | Read/Write | Gets or sets the declared next attachment id. |
| `declared_recipient_count` | `int \| None` | Read/Write | Gets or sets the declared recipient count. |
| `declared_attachment_count` | `int \| None` | Read/Write | Gets or sets the declared attachment count. |

## Methods

| Signature | Description |
|-----------|-------------|
| `from_file(path: Path \| str, strict: bool)` → `"MapiMessage"` | Calls from_file(path, strict) on this MapiMessage instance. |
| `from_msg_document(document: MsgDocument)` → `"MapiMessage"` | Calls from_msg_document(document) on this MapiMessage instance. |
| `from_email_message(email_message: EmailMessage, unicode_strings: bool)` → `"MapiMessage"` | Calls from_email_message(email_message, unicode_strings) on this MapiMessage instance. |
| `create(subject: str, body: str, unicode_strings: bool)` → `"MapiMessage"` | Calls create(subject, body, unicode_strings) on this MapiMessage instance. |
| `iter_properties()` → `Iterator[MapiProperty]` | Calls iter_properties on this MapiMessage instance. |
| `iter_property_keys(storage_stream_id: int)` → `Iterator[tuple[int, int]]` | Calls iter_property_keys(storage_stream_id) on this MapiMessage instance. |
| `set_property(property_id: int \| CommonMessagePropertyId \| PropertyId, property_type_or_value: int \| PropertyTypeCode \| Any, value: Any, flags: int)` → `MapiProperty` | Sets the property value. |
| `get_property(property_id: int \| CommonMessagePropertyId \| PropertyId, property_type: int \| None, storage_stream_id: int \| None, decode: bool \| None)` → `MapiProperty \| Any \| None` | Calls get_property(property_id, property_type, storage_stream_id, decode) on this MapiMessage instance. |
| `get_property_value(property_id: int \| CommonMessagePropertyId \| PropertyId, property_type: int \| None, storage_stream_id: int, decode: bool)` → `Any \| None` | Calls get_property_value(property_id, property_type, storage_stream_id, decode) on this MapiMessage instance. |
| `set_named_property(named_property: MapiNamedProperty, property_type: int \| PropertyTypeCode, value: Any, flags: int)` → `MapiProperty` | Sets the named property value. |
| `get_named_property(named_property: MapiNamedProperty, property_type: int \| None)` → `MapiProperty \| None` | Calls get_named_property(named_property, property_type) on this MapiMessage instance. |
| `add_recipient(email_address: str, display_name: str \| None, recipient_type: int)` → `MapiRecipient` | Calls add_recipient(email_address, display_name, recipient_type) on this MapiMessage instance. |
| `add_attachment(filename: str, data: bytes, mime_type: str \| None, content_id: str \| None)` → `MapiAttachment` | Calls add_attachment(filename, data, mime_type, content_id) on this MapiMessage instance. |
| `add_embedded_message_attachment(message: "MapiMessage", filename: str \| None, mime_type: str \| None)` → `MapiAttachment` | Calls add_embedded_message_attachment(message, filename, mime_type) on this MapiMessage instance. |
| `save(path: Path \| str)` | Calls save(path) on this MapiMessage instance. |
| `to_bytes()` → `bytes` | Calls to_bytes on this MapiMessage instance. |
| `to_email_message()` → `EmailMessage` | Calls to_email_message on this MapiMessage instance. |
| `to_email_bytes()` → `bytes` | Calls to_email_bytes on this MapiMessage instance. |
| `to_email_string()` → `str` | Calls to_email_string on this MapiMessage instance. |
| `iter_attachments_info()` → `Iterator[MapiAttachment]` | Calls iter_attachments_info on this MapiMessage instance. |
| `close()` | Calls close on this MapiMessage instance. |
| `to_msg_document()` → `MsgDocument` | Calls to_msg_document on this MapiMessage instance. |

## See Also

- [Aspose.Email for Python — Enterprise API Reference](https://reference.aspose.com/email/python-net/aspose.email.mapi/mapimessage/)