Skip to main content

Read contents, metadata and attachments from Outlook Message files

Project description

outlook_msg

Build Status

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.

Getting Started

Install using pip:

pip install outlook_msg

Usage

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[0]
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outlook_msg-1.0.0.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

outlook_msg-1.0.0-py3-none-any.whl (11.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page