2

I am using the IMAPclient to get the content of emails, so i made this piece of code :

messages = server.search(['FROM', user['email']], charset='UTF-8')
if len(messages) > 0:
    for mail_id, data in server.fetch(messages, ['ENVELOPE']).items():
        envelope = data[b'ENVELOPE']

How can I have the content of the emails?

asa
  • 531
  • 1
  • 5
  • 20

1 Answers1

5

Don't know if you found the answer elsewhere... try:

   messages = server.search(['FROM', user['email']], charset='UTF-8')
   if len(messages) > 0:
       for mail_id, data in server.fetch(messages,['ENVELOPE','BODY[TEXT]']).items():
           envelope = data[b'ENVELOPE']
           body = data[b'BODY[TEXT]']

The email content is in body.