Get email content

0

I'm using the following:

import imaplib
import email

m = imaplib.IMAP4_SSL("imap.gmail.com", 993)
m.login("myemail","mypass")
m.select("Inbox")

result, data = m.uid('search', None, "ALL") # search all email and return uids
if result == 'OK':
    for num in data[0].split():
        result, data = m.uid('fetch', num, '(RFC822)')
        if result == 'OK':
            email_message = email.message_from_string(data[0][1])    # raw email text including headers
            print 'From:' + email_message['subject'] 

m.close()
m.logout()

I can only get the Subject of the email, and I want the content of the message. What are the values besides subject and from?

Using python 2.7

    
asked by anonymous 09.04.2018 / 21:07

1 answer

0

Hello

I think this post can help you with this question friend:

Using imaplib As a suggestion I leave the IMAPClient library that I find much simpler to work with. Description of these:

  

Easy-to-use, Pythonic and complete IMAP client library.

    
10.04.2018 / 14:05