Get email message mymailbox.msg file : Email « Network « Python






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

1.Print out email message from your email box
2.Send email to two receivers
3.Sending Some E-Mail
4.MIME Multipart Messages
5.Send an email
6.Login to POP3 server and retrieve information
7.Sending Mail over an SMTP Connection