We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Ruby script that will export your Groupwise appointments to an iCal file
Homepage: http://timshadel.com/2005/12/14/ruby-groupwise-export-to-ical/
Clone URL: git://github.com/timshadel/groupwise-to-ical.git
Tim Shadel (author)
Sat Apr 05 08:06:09 -0700 2008
groupwise-to-ical / gw2ical.rb
100644 66 lines (59 sloc) 2.08 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'win32ole'
require 'icalendar'
 
class Attendee
  attr :mailto, true
  attr :params, true
 
  def initialize(mailto, params={})
    self.mailto = mailto
    self.params = params
  end
 
  def property_name
    param_str = ""
    params.each do |key, value|
      param_str << ";" if param_str.empty?
      param_str << "#{key}=#{value}"
    end
    "ATTENDEE#{param_str}"
  end
 
  def value
    "MAILTO:#{mailto}"
  end
end
 
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
cal.custom_property("METHOD", "PUBLISH")
cal.custom_property("X-WR-CALNAME;VALUE=TEXT", "ASRS GroupWise Calendar")
message_list = []
account.Calendar.Messages.each do |message|
  next unless message.ClassName == "GW.MESSAGE.APPOINTMENT"
  next if message_list.include? message.CommonMessageID
  message_list << message.CommonMessageID
  event = cal.event # This automatically adds the event to the calendar
  the_date = ParseDate.parsedate(message.CreationDate)
  event.timestamp = DateTime.civil(*the_date.compact!)
  event.location = message.Place
  event.organizer = "MAILTO:#{message.Sender.EmailAddress}"
  event.property_params["ORGANIZER"] = {}
  event.property_params["ORGANIZER"]["CN"] = message.FromText
  message.ExpandedRecipients.each do |recipient|
    if !recipient.Address.nil?
      address = recipient.Address.EmailAddress
    else
      address = recipient.EmailAddress
    end
    attendee = Attendee.new(address, {"CN" => recipient.DisplayName})
    event.custom_property attendee.property_name, attendee.value
  end
  event.summary = message.subject.PlainText
  event.description = message.BodyText.PlainText
  the_date = ParseDate.parsedate(message.StartDate)
  event.start = DateTime.civil(*the_date.compact!)
  the_date = ParseDate.parsedate(message.EndDate)
  event.end = DateTime.civil(*the_date.compact!)
end
 
cal.to_ical.each_line do |line|
  puts line.chomp
end