Automating Outlook With Ruby: Calendar Appointments
Join the DZone community and get the full member experience.Join For Free
From the Ruby on Windows blog. Use Ruby to extract appointments data from the Microsoft Outlook Calendar, delete an appointment, and create a new appointment.
require 'win32ole' outlook = WIN32OLE.new('Outlook.Application') mapi = outlook.GetNameSpace('MAPI') calendar = mapi.GetDefaultFolder(9) # reading calendar data data =  calendar.Items.each do |appointment| rec =  rec << appointment.Subject rec << appointment.Location rec << appointment.Start rec << appointment.Duration rec << appointment.End rec << appointment.Body data << rec end # deleting an appointment calendar.Items.each do |appointment| if appointment.Subject == 'Punch Bud Selig in the Nose' appointment.Delete end end # creating a new appointment appointment = outlook.CreateItem(1) appointment.Start = '7/29/2007 11:00 AM' appointment.Duration = 300 appointment.Subject = 'Baseball Hall of Fame Induction' appointment.Body = 'Tony Gwynn and Cal Ripken Jr.' appointment.Location = 'Cooperstown, NY' appointment.ReminderMinutesBeforeStart = 15 appointment.ReminderSet = true appointment.SaveFurther details and discussion can be found here.