Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 15 lines (11 sloc) 0.482 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Takes a load of messages from an Evolution IMAP directory and morphs them into
# an mbox file, so that they can, er, be imported into Evolution!

require "time"

messages = Dir[File.dirname(__FILE__) + "/*."].map { |message| File.read(message) }
messages = messages.map do |message|
  from = message[/^From: .*$/]
  from_email = from[/<[^>]+>/][1..-2]
  date = Time.parse(message[/^Date: .*$/][6..-1])
  
  "From #{from_email} #{date.asctime}\n" + message
end

puts messages.join
Something went wrong with that request. Please try again.