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
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:
Then you can add/remove records to the contacts folder and they will be delegated to all Exchange clients.