Reputation: 31
I am trying to access the Chat Folder using imaplib but am not able to do so. The code mail.select("Chats")
doesn't work since "chats" is not actually a label.
How do I access the emails in the Chats folder?
Upvotes: 3
Views: 907
Reputation: 1185
any folder you want to access by imap. it should be allowed by mail server.
e.g : for gmail, check below image for, how to set access of imap.
here, "Show in IMAP" should be checked for "Chats" folder.
then after, try below code snippets:
sock = imaplib.IMAP4_SSL("imap.gmail.com", 993)
sock.login("your Email Id", "Password")
lb_list = sock.list() # print
#search for "Chats" folder and its signature
#here, it is "[Gmail]/Chats"
sock.select("[Gmail]/Chats", True)
sock.search(None, '(ALL)')
resp, data = sock.fetch('1:*', '(RFC822)')
Hope, it will be helpful.
Upvotes: 4