Install & Compatibility
Where this runs
tested against v0.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.128s · 19.7MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.8s · import 0.122s · 20MB
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Message
✓ from oxmsg import Message
Main class for loading and parsing .msg files.
Loads a .msg file, accesses its properties like message class and attachment count, and demonstrates how to retrieve attachment details, including their content if available. Note that a real .msg file is required for actual parsing.
import os
from oxmsg import Message
# Create a dummy .msg file for demonstration purposes
# In a real scenario, you would have an actual .msg file
dummy_msg_content = b"""
This is a placeholder for a .msg file content.
In a real application, this would be binary data.
"""
with open("message.msg", "wb") as f:
f.write(dummy_msg_content)
try:
msg = Message.load("message.msg")
print(f"Message Class: {msg.message_class}")
print(f"Attachment Count: {msg.attachment_count}")
if msg.attachment_count > 0:
attachment = msg.attachments[0]
print(f" Attachment File Name: {attachment.file_name}")
print(f" Attachment MIME Type: {attachment.mime_type}")
print(f" Attachment Size: {attachment.size}")
if attachment.attached_by_value:
print(f" Attachment Bytes (first 20): {attachment.file_bytes[:20]}...")
# Example of saving attachment:
# with open(attachment.file_name, "wb") as f:
# f.write(attachment.file_bytes)
else:
print(" Attachment bytes not available directly (attached by reference).")
else:
print("No attachments found.")
except Exception as e:
print(f"Error processing MSG file: {e}")
finally:
# Clean up the dummy file
if os.path.exists("message.msg"):
os.remove("message.msg")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'oxmsg'
The 'python-oxmsg' package is not installed in your current Python environment.
fixpip install python-oxmsg
AttributeError: module 'oxmsg' has no attribute 'Oxmsg'
You are trying to access the 'Oxmsg' class as an attribute of the 'oxmsg' module after using 'import oxmsg', but the class needs to be imported directly.
fixfrom oxmsg import Oxmsg
TypeError: Oxmsg() missing 1 required positional argument: 'filepath'
The 'Oxmsg' class constructor requires the path to the Outlook MSG file as its first argument.
fixmsg = Oxmsg('path/to/your/outlook_email.msg') FileNotFoundError: [Errno 2] No such file or directory: 'your_file.msg'
The provided file path for the Outlook MSG (.msg) file is incorrect, or the file does not exist at the specified location.
fixEnsure the file path is correct and the '.msg' file exists in the specified directory or provide an absolute path.
Upgrade
Version history
0.0.2latest on PyPI · released Feb 3, 2025
Audit
Dependencies
clickrequiredUsed for the command-line interface.
olefilerequiredHandles the underlying OLE Structured Storage format of .msg files.
typing_extensionsrequiredProvides backported and experimental type hints.