Skip to main content

Python package for extracting metadata, text, html and attachements from email messages.

Project description

emaildata is a python package for extracting content from email messages. It is a fork of the emailcontent package but adds from features.

emaildata features

emaildata extracts this types of contents from emails:

  • Extract metadata.

  • Extract text (plain text and html).

  • Extract attachments.

Extracting metadata

This feature was included from the metadata module of the emailcontent. This module was copied module, few methods of is MetaData class were removed, and the module was made more pylint friendly.

To extract metadata from an email message headers you create an instance of the MetaData class passing a message to the constructor. You can retrieve the metadata with the method to_dict. This can also be done using the method set_message:

#!python

import email
from emaildata.metadata import MetaData

message = email.message_from_file(open('message.eml'))
extractor = MetaData(message)
data = extractor.to_dict()
print data.keys()

message2 = email.message_from_file(open('message2.eml'))
extractor.set_message(message2)
data2 = extractor.to_dict()

Extracting text

The class Text in the text module have static methods for extracting text and html from messages:

#!python

import email
from emaildata.text import Text

message = email.message_from_file(open('message.eml'))
text = Text.text(message)
html = Text.html(message)

Extracting attachments

Comming soon…

Changelog

Version 0.2 (2015-05-3)

  • Implemented class for extracting plain text and html from messages.

Version 0.1 (2015-03-15)

  • Initial version.

  • Support for metadata extraction.

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

emaildata-0.2.0.tar.gz (5.5 kB view hashes)

Uploaded Source

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