require 'rubygems'
require 'viewpoint'

# Get the instance of Viewpoint.  This is a singleton class and will
# have only one instance ever instantiated no matter how many times
# you call #instance
vp = Viewpoint::ExchWebServ.instance

# Set authentication parameters (probably NTLM)
vp.authenticate

# This actually calls EWS's FindFolder SOAP message
vp.find_folders

# Get the instance 'Calendar' and convert it
cal = vp.get_folder("Calendar")
ical = cal.to_ical
puts ical.to_ical

# See: http://github.com/zenchild/Viewpoint/blob/master/lib/viewpoint/calendar.rb#L105 for more
# in depth information about what is going on.