2

I have an IMAP folder somewhere containing thousands of attached files.

How to download all of these attachments?

  • A program focused on this task is preferred, not a human-facing email reading/composing program that happens to also download attachments if you click here and there
  • Command-line tool preferred
  • Free, ideally open source

2 Answers 2

1

You could do this with a python script, the following example would download and print the text from all messages, (courtesy of the python documents).

import getpass, imaplib

M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(RFC822)')
    print 'Message %s\n%s\n' % (num, data[0][3])
M.close()
M.logout()

But in your case you need to specify the attachments as in this SO answer, (second one looks to fill your needs).

  • Free
  • Command Line
  • Customisable
  • Open Source
  • Just about any platform from Raspberry Pi to a super computer cluster even OS-X or Windows
1

Mozilla Thunderbird has an attachment extractor addon which can be instructed to extract attachments from an entire IMAP folder at once. It also can remove attachments from e-mails after extraction to save space (which is the main reason I extract attachments).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.