Read contents, metadata and attachments from Outlook Message files
outlook_msg is a Python library by Hamilton Group to process the .msg files that
Users can export from Outlook. It is very common for users in organizations that use Outlook to archive data in this
format. For example, at Hamilton we see these files store in relation to deals we write. If we want to do automatic
processing in a way that feels most natural to end users we need to extract data from these files.
This library is built on top of the excellent compoundfiles library, without which none of this would be possible.
Install using pip:
pip install outlook_msg
To open an email:
from outlook_msg import Message with open('file.msg') as msg_file: msg = Message(msg_file) # Contents are the plaintext body of the email contents = msg.body # Attachments can be read and saved like so first_attachment = msg.attachments with first_attachment.open() as attachment_fp, open(first_attachment.filename, 'wb') as output_fp: output_fp.write(attachment_fp.read())
Running the tests
We use pytest to run our tests but you are best to use tox so you can test on all supported Python versions and will ensure a clean environment.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for outlook_msg-1.0.0-py3-none-any.whl