I am trying to print the content of the mail ( Mail body) using Python mailbox.
import mailbox
mbox = mailbox.mbox('Inbox')
i=1
for message in mbox:
print i
print "from :",message['from']
print "subject:",message['subject']
print "message:",message['**messages**']
print "**************************************"
i+=1
But I feel message['messages'] is not the right one to print the mail content here. I could not understand it from the documentation
To get the message content, you want to use
get_payload()
.mailbox.Message
is a subclass ofemail.message.Message
. You'll also want to checkis_multipart()
because that will affect the return value ofget_payload()
. Example:this function can give you message body if the body is plain text.