Skip to content

An EMLX file contains an individual email message created by Apple Mail

License

Notifications You must be signed in to change notification settings

crb912/emlx_parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emlx_parse

An EMLX file contains an individual email message created by Apple Mail

Description

emlx_parse takes as input a raw emlx email and generates a parsed object. The properties of this object are the same name of RFC headers:

  • bcc
  • cc
  • date
  • delivered_to
  • from_ (not from because is a keyword of Python)
  • message_id
  • received
  • reply_to
  • subject
  • to

There are other properties to get:

  • body
  • body html
  • body plain
  • headers
  • attachments

Usage in a project

Import emlx_parse module:

import emlx_parse

sample_file_path = r'./test/sample/1.emlx'
my_eml = emlx_parse.Emlx(sample_file_path, decode=True)

Then you can get all parts

# Header
print(my_eml.header.subject)
print(my_eml.header.from_)
print(my_eml.header.to)
print('sent date:', my_eml.header.date_utc)
print('received date:', my_eml.header.received.date_utc)
print(my_eml.header.cc)
print(my_eml.header.bcc)

# Body
for part in my_eml.body:
    if part.text_plain:
        print('# TEXT #', part.text_plain)
    if part.text_html:
        print('# HTML #', part.text_html)
    # save image
    if part.image:
        print('my image')
        with open(part.filename, 'wb') as fh:
            fh.write(part.image)
    # save other attachment
    if part.attachment:
        with open(part.filename, 'wb') as fh:
            fh.write(part.attachment)

About

An EMLX file contains an individual email message created by Apple Mail

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages