I'm currently trying to write a script that gets messages from my gmail account but I'm noticing a problem. If poplib loops through a message in my inbox it will never loop through it again. Here is my code
import poplib, string, email
user = "
[email protected]"
password = "p0ckystyx"
message = ""
mail = poplib.POP3_SSL('pop.gmail.com')
mail.user(user)
mail.pass_(password)
iMessageCount = len(mail.list()[1])
message = ""
msg = mail.retr(iMessageCount)
str = string.join(msg[1], "\n")
frmMail = email.message_from_string(str)
for part in frmMail.walk():
if part.get_content_type() == "text/plain":
print part.get_payload()
mail.quit()
Every time I run this script it goes to the next newest email and just skips over the email that was shown last time it was run.