Answer the question
In order to leave comments, you need to log in
Get the body of a python email?
Essence: there is a code that pulls an unread letter from the box, There are 2 links in the letter.
Together with the letter I receive everything at once, but only the body is needed, how to implement it?
import imaplib
import email
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('mail, pass')
mail.list()
mail.select() # connect to inbox.
typ, data = mail.search(None, '(FROM "krikynchik")')
f=open('data', 'w')
for num in data[0].split():
typ, data = mail.fetch(num, '(RFC822)')
f.write('Message %sn%sn' % (num, data[0][1]))
f.close()
mail.close()
mail.logout()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question