delete all email


import imaplib
box = imaplib.IMAP4_SSL('imap.mail.microsoftonline.com', 993)
box.login("user@nextag.microsoftonline.com","password")
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()

Advertisements

One thought on “delete all email

  1. Utsav says:

    This code wont work when inbox is bulky

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: