Last active
October 26, 2018 20:25
-
-
Save u1735067/1700fc81856b53ff3137617c151ec260 to your computer and use it in GitHub Desktop.
Little time-saver script, because Microsoft's Outlook.com UI is not able to cancel/rollback a "Delete all" action (no operation possible on Trash's Select all)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://imapclient.readthedocs.io/en/2.1.0/ | |
# https://imapclient.readthedocs.io/en/2.1.0/api.html#module-imapclient.testable_imapclient | |
# py -m pip install imapclient | |
import imapclient | |
server = imapclient.IMAPClient('outlook.office365.com') | |
server.login('user', 'pass) | |
server.select_folder('Deleted') | |
messages = server.search() | |
total_move = len(messages) | |
moved = 0 | |
per_call = 100 | |
while len(messages) > 0: | |
to_move = min(per_call, len(messages)) | |
moving = messages[0:to_move] | |
try: | |
server.move(moving, 'Inbox') | |
del messages[0:to_move] | |
moved += to_move | |
print('Done {}/{} ({}%)'.format(moved, total_move, int(moved/total_move*100))) | |
except Exception as e: | |
print('Failed {}/{} ({}%) : {}'.format(moved, total_move, int(moved/total_move*100), e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment