The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Outlook Appointments with Ruby

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Britt

Posts: 1319
Nickname: jamesbritt
Registered: Apr, 2003

James Britt is a principal in 30 Second Rule, and runs ruby-doc.org and rubyxml.com
Outlook Appointments with Ruby Posted: May 26, 2005 6:08 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by James Britt.
Original Post: Outlook Appointments with Ruby
Feed Title: James Britt: Ruby Development
Feed URL: http://feeds.feedburner.com/JamesBritt-Home
Feed Description: James Britt: Playing with better toys
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by James Britt
Latest Posts From James Britt: Ruby Development

Advertisement

By the standards of some 1337ists, I am a child of a lesser god: I confess to using Windows. If you share this disdain, then avert your eyes.

However, if you use Outlook, and care to see how to use Ruby to add appointments to the Outlook calender, then read on.

I've gradually been migrating off of Microsoft products, but as a calender app Outlook 2000 serves me better than the alternatives I've examined. (I expect that in some possible future I may move to Sunbird, but it isn't quite there yet for me.)

I mostly use Outlook to remind me to do basic stuff, such as move the trash bin to the curb for pick-up, or set the VCR to tape House. (Analog rules!) Adding items can be tedious, though, what with assorted selecting and clicking and saving. What I really wanted was a way to add stuff from the command line (which I hear is how most Mac users do things, actually).

After a bit of poking around I found assorted example of scripting Outlook via the COM interface. I swiped some moves and came up with this class:

require 'win32ole'

require 'date'

 

class Outlook

 

OLFolderCalendar = 9 OLAppointmentItem = 1 OLFree = 0 OLTentative = 1 OLBusy = 2

 

SEC = 1 MIN = 60 * SEC HOUR = MIN * 60 def initialize( busy_default = Outlook::OLBusy ) @ol = WIN32OLE.new( "Outlook.Application" ) @busy_default = busy_default end

 

def add_appointment( opts ) opts[ :busy_status ] ||= @busy_default ol_appt = @ol.CreateItem( OLAppointmentItem ) ol_appt.Start = opts[ :start ] ol_appt.End = opts[ :end ] ol_appt.Subject = opts[ :subject ] ol_appt.Location = opts[ :location ] ol_appt.Body = opts[ :body ] ol_appt.BusyStatus = opts[ :busy_status ] ol_appt.ReminderSet = opts[ :set_reminder? ] ol_appt.ReminderMinutesBeforeStart = opts[ :reminder_minutes ] ol_appt.Save end

 

end

 

if __FILE__ == $0

ol = Outlook.new start_time = Time.local( 2005, 5, 27, 14, 0, 0 ) end_time = start_time + ( 120 * Outlook::MIN ) ol.add_appointment :start => start_time, :end => end_time , :subject => 'Testing Ruby!', :location => "Flatland", :body => 'Just testing stuff', :set_reminder? => true, :reminder_minutes => 120

end

 

Season to taste.

Now writing small scripts that grab ARGV and add calender items is simpler than clicking a one-button mouse.

Proof left as an exercise for the reader.

Read: Outlook Appointments with Ruby

Topic: That's what I'm talking about Previous Topic   Next Topic Topic: Setting up continuous integration with CIA

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use