Get email message mymailbox.msg file
import rfc822
mailbox_filename = "mymailbox.msg"
file_handle = open("mailbox_filename")
messagedic = rfc822.Message(file_handle)
content_type = messagedic["content-type"]
from_field = messagedic["From"]
to_field = messagedic.getaddr("To")
subject_field = messagedic["Subject"]
file_handle.close()
print content_type, from_field, to_field, subject_field
Related examples in the same category