Zlatan Zlatanov
May 9, 2014 · 1 min read

As a Rails developer I sometimes face the challenge to work with Microsoft servers and services.

My latest challenge was to get Rails working with Windows Exchange server.

Microsoft Exchange Server is calendaring software, a mail server and contact manager. My task was to make it possible to sync contacts from a Rails application to the Exchange server. This appears to be very time consuming task if you write the API protocol from scratch.

Fortunately there are couple of Ruby gems which you can use. I used the ‘viewpoint’ (https://github.com/WinRb/Viewpoint) gem since it covers what I needed and is the most up to date among all others. The installation and configuration of the gem itself is fairly easy:
gem install viewpoint or gem 'viewpoint' in your gemfile then bundle install

Then you need to configure it’s endpoint:

endpoint = 'https://example.com/ews/Exchange.asmx'

user = 'username'

pass = 'password'

And establish the connection:
cli = Viewpoint::EWSClient.new endpoint, user, pass

The other part is to install and configure the Exchange server. For this you will need x64 Windows or Windows server. It may be tricky to get it working on Windows server (R8) because Exchange server won’t install without it’s .NET framework requirements. I used x64 Windows7 professional edition and a latest version of Exchange server (http://technet.microsoft.com/en-US/evalcenter/hh973395.aspx?wt.mcid=TEC116133) along with .NET 4. After installing the Exchange server I was able to connect to it through Rails and query contacts folder:
cli.get_folder :contacts

Then you can add/remove records to the contacts folder and they will be delegated to all Exchange clients.

Evermore

Development consultancy, specialised in building custom web solutions and applications since 2006. Visit us at: http://weareevermore.com

Zlatan Zlatanov

Written by

Evermore

Evermore

Development consultancy, specialised in building custom web solutions and applications since 2006. Visit us at: http://weareevermore.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade