Getting errors from Imaplib - reloaded
Beatrix Willius from Moth Software
mail at beatrixwillius.de
Wed Dec 10 11:41:22 EST 2014
Hi,
thanks to your help I can get traceback errors for the imaplib. But what about accessing direct imap errors? In the following part of my script I can't select the not-deleted mails for some reason. But how do I access the error? The debugger goes to the exception line but OSError.strerror doesn't have anything. And print(imaplib.IMAP4.error) only gives me <class 'imaplib.IMAP4.error'> as result.
import imaplib
host = "xxx"
username = "bla"
password = "blub"
mailbox = "\"Ablage.Kunden\""
imap_connection = imaplib.IMAP4(host)
result, data = imap_connection.login(username, password)
result, data = imap_connection.select(mailbox, True)
try:
result, messages_data = imap_connection.search(None, "NOT DELETED")
print('okay')
except (imaplib.IMAP4.error, OSError):
#print(OSError.strerror)
#print(imaplib.IMAP4.error)
print('xxxerrorxxx: select mails exception')
imap_connection.logout()
Mit freundlichen Grüßen/Regards
Trixi Willius
http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
More information about the Python-list
mailing list