UPDATE: I’ve posted a more complete version of this code in More Ruby Exporting of Groupwise to iCal.

I’ve wanted to export my Groupwise calendar to iCal format for a long time. Every time I try to do it, I ended up running into the same few pages. They sorta worked, but were clumsy.

So I threw this little beauty together in under 10 minutes and 2 google searches. It seems to be a start, though I expect to improve it. Groupwise Object API Docs (PDF format; the web version keeps blinking — arrrgh) from Novell were useful, as was this Ruby gem.

require 'win32ole'
require 'icalendar'

groupwise = WIN32OLE.new("NovellGroupWareSession")
# 2nd arg is not password, so leave blank
account = groupwise.Login("your-username", "")
path_to_host = account.PathToHost
cal = Icalendar::Calendar.new
account.Calendar.Messages.each do |message|
  next unless message.ClassName == "GW.MESSAGE.APPOINTMENT"
  event = cal.event  # This automatically adds the event to the calendar
  event.user_id = "tims@asrs.state.az.us"
  event.timestamp = DateTime.now
  event.summary = message.subject.PlainText
  event.description = message.BodyText.PlainText
  event.start = message.StartDate
  event.end = message.EndDate

puts cal.to_ical

Every day I find more reasons to love using Ruby. Enjoy!

comments powered by Disqus