How can I delete messages from the mail box? I am using this code, but the letters are not removed. Sorry for my English.
def getimap(self,server,port,login,password): import imaplib, email box = imaplib.IMAP4(server,port) box.login(login,password) box.select() box.expunge() typ, data = box.search(None, 'ALL') for num in data[0].split() : typ, data = box.fetch(num, '(UID BODY[TEXT])') print num print data[0][1] box.close() box.logout()
Step 1: Shift to the Mail view, and click to open the specified IMAP folder that you will purge all messages marked for deletion. Step 2: Click the Purge > Purge Marked Items in “Inbox” on the Folder tab.
Yes, the IMAP sync deleted messages from server. It means, if you delete a message, it will get removed from the server. This article will guide you about IMAP synchronization.
No, disabling the account won't delete anything. But it should remove any files stored in IMAP on the computer. Since it is disabled, it no longer communicates with the server and will have no actions with the server site.
If you have an IMAP, or HTTP (such as Gmail or Outlook.com ) account, mail isn't stored on your computer. All email remains on the mail server until you delete it.
This is the working code for deleting all emails in your inbox:
import imaplib box = imaplib.IMAP4_SSL('imap.mail.microsoftonline.com', 993) box.login("[email protected]","paswword") box.select('Inbox') typ, data = box.search(None, 'ALL') for num in data[0].split(): box.store(num, '+FLAGS', '\\Deleted') box.expunge() box.close() box.logout()
I think you should mark the emails to be deleted, first.. For example:
for num in data[0].split(): box.store(num, '+FLAGS', '\\Deleted') box.expunge()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With