I have been a able to select gmail spam folder and outlook spam folder using this code
'[Gmail]/Spam' and 'Junk'
but i have not been able to do the same for yahoomail
the below is my code
smt = 'imap.mail.yahoo.com'
with MailBox(smt).login('******@yahoo.com', 'password', initial_folder='Inbox') as mailbox:
for f in mailbox.folder.list():
print(f)
Below is the result of this code
{'flags': ('\\Archive', '\\HasNoChildren'), 'delim': '/', 'name': 'Archive'}
{'flags': ('\\Junk', '\\HasNoChildren'), 'delim': '/', 'name': 'Bulk Mail'}
{'flags': ('\\Drafts', '\\HasNoChildren'), 'delim': '/', 'name': 'Draft'}
{'flags': ('\\HasNoChildren',), 'delim': '/', 'name': 'Inbox'}
{'flags': ('\\Sent', '\\HasNoChildren'), 'delim': '/', 'name': 'Sent'}
{'flags': ('\\Trash', '\\HasNoChildren'), 'delim': '/', 'name': 'Trash'}
I really don't know how to go about selecting the spam folder, i really need this help please.
What about:
with MailBox(SMTP_SERVER).login(FROM_EMAIL, FROM_PWD, initial_folder = 'Bulk Mail') as mailbox:
# EXISTS: check is folder exists (shortcut for list)
current_folder = mailbox.folder.get()
subjects2 = [msg.subject for msg in mailbox.fetch()]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.