Skip to content

Instantly share code, notes, and snippets.

@waldekmastykarz
Created August 6, 2020 18:19
Show Gist options
  • Save waldekmastykarz/bc75ad7c4dca0bc1cd81cdcfab516d4a to your computer and use it in GitHub Desktop.
Save waldekmastykarz/bc75ad7c4dca0bc1cd81cdcfab516d4a to your computer and use it in GitHub Desktop.
Move Outlook emails from Inbox to Archive
OFFICE365CLI_AADAPPID=31... OFFICE365CLI_TENANT=b4... m365 outlook message list --folderName inbox -o json --query '[].id' > emails.txt
i=0
cat emails.txt | jq -c '.[]' | while read msgId; do
i=$((i+1))
echo "Archiving $i..."
OFFICE365CLI_AADAPPID=31... OFFICE365CLI_TENANT=b4... m365 outlook message move --sourceFolderName inbox --messageId $msgId --targetFolderName archive
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment