Skip to content

Instantly share code, notes, and snippets.

@daicham
Created January 11, 2012 08:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daicham/1593705 to your computer and use it in GitHub Desktop.
Save daicham/1593705 to your computer and use it in GitHub Desktop.
Get Outlook calendar by ruby
require 'win32ole'
def each_meeting
ol = WIN32OLE.connect("Outlook.Application")
myNameSpace = ol.getNameSpace("MAPI")
folder = myNameSpace.GetDefaultFolder(9) # 9 は予定表
#folder.Display
folder.Items.each do |meeting|
GC.start
yield meeting
end
end
each_meeting do |m|
m.Recipients.each do |i|
puts m.Subject + ":" + m.Start + "-" + m.End + "@" + m.Location + ":" + m.Duration.to_s + ":" + m.Body + ":" + i.Name
end
end
@ipstone
Copy link

ipstone commented Dec 3, 2015

How to filer out the items by date range? I have tried Restrict methods, but it returns OLE error code 4096, and OLE method 'Restrict' is missing. I saw online where people saw similar issue, but no solution yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment