Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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 = Net::IMAP.new('mail.example.com')
  imap.authenticate('LOGIN', 'joe_user', 'joes_password')
  imap.examine('INBOX')
  imap.search(["NEW", "FROM", "example.from", "SUBJECT", "example subject"]).each do |message_id|
    body = imap.fetch(message_id, "BODY")[0].attr["BODY"]
    File.open('path to file', 'w') { |f| f.write(body) }
  end

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

 
discard

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.