My inbox has the most e-mail messages than in important and sent inboxes. I want to delete all letters that are not in the important or sent mailbox.
I cannot perform the following steps: 1) Delete all emails in the entire mailbox (when I delete all emails in the entire mailbox, all letters in important and sent mailboxes will be deleted at the same time)
2) and copy the letters from important and sent mailboxes.
How can I write code for this? The problem may become another form:
how can I make a copy of the letters in my gmailbox: "[Gmail] / & kc 2JgQ-" in the local directory g: \ mygmail?
There are 5 letters in my gmail inbox, I save them all in g: \ mygmails and name them as 0th.myemail 1th.myemail 2th.myemail 3th.myemail 4th.myemail with the following code, now how can I read them with thunderbird or email, i don't want to write my own code to read them?
import email,imaplib
att_path="g:\\mygmails\\"
user="xxxx"
password="yyyy"
con=imaplib.IMAP4_SSL('imap.gmail.com')
con.login(user,password)
con.select('INBOX')
resp, items = con.search(None, "ALL")
items = items[0].split()
for id,num in enumerate(items):
resp, data = con.fetch(num, "(RFC822)")
data=data[0][1]
fp = open(att_path+str(id)+"th"+".myemail", 'wb')
fp.write(data)
fp.close()
source
share