Dec-11-2024, 03:44 PM
Quote:So I have this simple program that checks my email
everything is working the way it should
I would like to have it print there are no new messages
but for some reason I can't get it to work
I have tried all kinds of if not scenarios
even message count
with no luck
I would appreciate any help
on why I can't get this to work
can someone please show me what I am doing wrong
try:
with MailBox(IMAP_SERVER).login(MAIL_USERNAME, MAIL_PASSWORD, "Inbox") as mb:
""" checks the status of the inbox """
stat = mb.folder.status("Inbox")
""" shows the number of unscene emails """
label_header1.insert(END, mb.folder.get() + f" - {stat['UNSEEN']}")
for msg in mb.fetch(criteria="UNSEEN", limit=7, reverse=True, mark_seen=False):
my_listbox1.insert(END, " " + msg.from_values.name)
my_listbox1.itemconfig(END, fg="#660000")
my_listbox2.insert(END, " " + msg.subject)
my_listbox2.itemconfig(END, fg="#006600")
#print(msg.subject, msg.date, msg.flags, msg.text, msg.uid)
except imap_tools.errors.MailboxLoginError:
label_header1.insert(END, "AUTHENTICATION FAILED Invalid credentials "
"(Failure: check your username or password)")
except imaplib.IMAP4.error:
label_header1.insert(END, "LOGIN command FAILED: check your username or password")
