Question

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.

Was it helpful?

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

OTHER TIPS

Try using Selenium to take the screenshots

I never tried it, but there are ways to take screenshots and ways to use Ruby

From the documentation :

capture_screenshot(filename)

Captures a PNG screenshot to the specified file.

‘filename’ is the absolute path to the file to be written, e.g. "c:\blah\screenshot.png" 

You can also take a look at Page Glimpse for these tasks.

The you need to find a way to automatize the "open email / take screenshot" procedure using this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top