2

Thanks to several users on here, I now am able to connect to the server via IMAP and download all of the unread messages. The problem, however, is that themessages are not in a readable form. Do I need to figure out a way to render the HTML in my application?

Here is my code:

import imaplib

server = imaplib.IMAP4_SSL('imap.gmail.com')
server.login('USER', 'PASS')

server.select('INBOX')

resp, items = server.search(None, "(UNSEEN)")

for mail in items[0].split():
    resp, data = server.fetch(mail, '(RFC822)')
    body = data[0][1]
    print body
3
  • 4
    I hope that's not your real password. Commented Jun 8, 2011 at 19:14
  • change it really fast. This is a public website. Commented Jun 8, 2011 at 19:16
  • @Gabi, It's already been changed. Thanks again! Commented Jun 8, 2011 at 19:16

1 Answer 1

1

Have a look at the email module. It can help you extract the data you want from the message body.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.