Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a program that will allow me to connect to my mail server (IMAP) and automatically save certain new e-mails to disk? Multiple times a day I receive automated e-mail updates about pending jobs from a system that processes some information for us. The data in these e-mails is written as plain-text within the body of the message. I would like to download the newest message, parse it, and display it on my desktop. The last two parts I can manage ok - it's just the automatic downloading that is posing a challenge.

I don't use Outlook (I do use Thunderbird), but would prefer not to have the client open to make this happen. I'm currently running Win7.

share|improve this question

I'd approach this by writing a script. Ruby has an IMAP library, and I assume Perl and Python do as well if those are more to your tastes.

Here's a rough, untested cut in Ruby (which you'll need to install on your windows machine to use) based on an example from the IMAP docs here

  imap ='')
  imap.authenticate('LOGIN', 'joe_user', 'joes_password')
  imap.examine('INBOX')["NEW", "FROM", "example.from", "SUBJECT", "example subject"]).each do |message_id|
    body = imap.fetch(message_id, "BODY[TEXT]")[0].attr["BODY[TEXT]"]'path to file', 'a') { |f| f.write(body) }

You can change the parameters passed to search as you need to to identify your messages. Install ruby, save this script as a text file and set it up to run as a scheduled task every few minutes and you should get your text file with the message body.

share|improve this answer
Thanks! I don't have much programming experience beyond AutoHotKey (as much as it can be considered programming), but I might give this a shot and see what happens. – CatamountJack Feb 22 '11 at 3:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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