Skip to content

Instantly share code, notes, and snippets.

View marcocox's full-sized avatar

Marco Cox marcocox

View GitHub Profile
@marcocox
marcocox / download_mailbox_csv_attachments.py
Last active October 5, 2022 13:38
Python script to download CSV file attachments from an IMAP mailbox
# Download all csv file attachments from an IMAP mailbox, save in working dir, delete email(s) afterwards.
# IMPORTANT: all emails are deleted, even the ones that do not have (csv) attachments.
# Usage: python3 download_mailbox_csv_attachments.py {imap_host} {username} {password}
import imaplib, email, os, sys, random
if len(sys.argv) != 4:
print('Invalid number of arguments')
exit(1)