Convert an Outlook Email File to PNG in Ruby

If you don’t have an Outlook account, opening an EML file can be a real pain. To avoid having to download and install a separate reader or program just to view the file, you can use the following API in Ruby to automatically convert the EML file to JPG/JPEG image array.

To begin, we will add the Ruby client to our Gemfile:

gem 'cloudmersive-convert-api-client', '~> 2.1.6'

Next, we can add the EML file and API key into the below example code to call the function:

# load the gem
require 'cloudmersive-convert-api-client'
# setup authorization
CloudmersiveConvertApiClient.configure do |config|
# Configure API key authorization: Apikey
config.api_key['Apikey'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['Apikey'] = 'Bearer'
end

This will also allow you to adjust the compression/quality level if you choose — the default is 75, but it can be set between 1–100 to meet your needs.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

436 Followers

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.