1import email
2from emaildata.attachment import Attachment
3
4message = email.message_from_file(open('message.eml'))
5for content, filename, mimetype, message in Attachment.extract(message):
6 print filename
7 with open(filename, 'w') as stream:
8 stream.write(content)
9 # If message is not None then it is an instance of email.message.Message
10 if message:
11 print "The file {0} is a message with attachments.".format(filename)
12
1import email
2from emaildata.metadata import MetaData
3
4message = email.message_from_file(open('message.eml'))
5extractor = MetaData(message)
6data = extractor.to_dict()
7print data.keys()
8
9message2 = email.message_from_file(open('message2.eml'))
10extractor.set_message(message2)
11data2 = extractor.to_dict()
12
1import email
2from emaildata.text import Text
3
4message = email.message_from_file(open('message.eml'))
5text = Text.text(message)
6html = Text.html(message)
7