---
Product: Aspose.Email
Platform: python
Page Type: docs
Canonical URL: https://docs.aspose.org/email/python/getting-started/quickstart
---

# Quickstart

Create and read an Outlook MSG file in Python in under five minutes using MapiMessage, PropertyId, and the aspose-email-foss package.

## Quickstart: Create and Read an MSG File

This guide takes you from a fresh install to a working MSG file in a few steps using
`MapiMessage` from `aspose.email_foss`.

---

### Prerequisites

| Requirement | Detail |
|---|---|
| Python | 3.10 or later |
| pip | current version |
| OS | Windows, macOS, or Linux |
| Dependencies | None — pure Python |

---

### Step 1 — Install the Package

```bash
pip install aspose-email-foss
```

Confirm the install:

```python
from aspose.email_foss.msg import MapiMessage
print("aspose-email-foss is ready.")
```

---

### Step 2 — Create an MSG File

Use `MapiMessage.create()` to build a message, set sender properties with `PropertyId`,
add a recipient, attach a file, and call `save()` to write the `.msg` output.

```python
from datetime import datetime, timezone
from aspose.email_foss import msg

message = msg.MapiMessage.create("Hello from Python", "This is the message body.")
message.set_property(msg.PropertyId.SENDER_NAME, "Build Agent")
message.set_property(msg.PropertyId.SENDER_EMAIL_ADDRESS, "agent@example.com")
message.set_property(
    msg.PropertyId.MESSAGE_DELIVERY_TIME,
    datetime(2026, 1, 1, 9, 0, tzinfo=timezone.utc),
)
message.add_recipient("alice@example.com", display_name="Alice Example")
message.add_attachment("readme.txt", b"Hello, world!\n", mime_type="text/plain")
message.save("quickstart.msg")
print("quickstart.msg written.")
```

---

### Step 3 — Read the MSG File Back

Load the saved file with `MapiMessage.from_file()` and access the `subject` and `body`
properties directly.

```python
from aspose.email_foss import msg

with msg.MapiMessage.from_file("quickstart.msg") as message:
    print(f"Subject : {message.subject}")
    print(f"Body    : {message.body}")
```

---

### Step 4 — Convert to EML

`to_email_message()` returns a standard Python `email.message.EmailMessage` object. Use
`to_email_bytes()` to write a ready-to-send RFC 5322 `.eml` file.

```python
from pathlib import Path
from aspose.email_foss import msg

with msg.MapiMessage.from_file("quickstart.msg") as message:
    Path("quickstart.eml").write_bytes(message.to_email_bytes())
    print("quickstart.eml written.")
```

---

### Next Steps

- [Installation Guide](installation/): Virtual-environment setup, pip options, and verification
- [Getting Started Overview](../): Prerequisites summary and capability overview
- [Features and Functionalities](../developer-guide/features/): Deep-dive into every feature
- [API Reference](https://reference.aspose.org/email/python/)

## See Also
- [Aspose.Email — Enterprise Documentation](https://docs.aspose.com/email/)