Search code examples
rubyscreenshotemaileml

Open eml file in any mail client and take screenshot


I perform a lot of tests that create e-mail messages. I store each message in separate eml file. (I can change file extension if needed.)

I would like to open each file in any mail client and take a screen shot, so I could visually inspect e-mails later.

The idea is that I could use a image viewing application to look at several screenshots in the same time, so I could visually compare them (after each test run).

I have access to Windows, Mac and Linux machines. I would prefer if the solution is in Ruby, but that is not required.

I am searching the web and this site, but no luck so far. I will post the solution in answer if I find it.


Solution

  • Looks like you can not automate Outlook Express. It accepts only newsonly and mailonly options when started from command line.

    Thunderbird accepts file name when started from command line:

    C:\>"C:\Program Files\Mozilla Thunderbird\thunderbird.exe" mail.eml
    

    That was all I needed to open an e-mail in a mail client.

    snapit.exe takes the screen shot and saves it to file.

    And here is the script to take the screen shot for multiple eml files.

    file_names.each do |file_name|
      `start /d "#{thunderbird_folder}" thunderbird.exe #{file_name}`
    
      # if the script does not wait for a second, screen shot will be taken before
      # thunderbird opens
      sleep 1
    
      `snapit.exe`
    end