Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Automating Outlook With Ruby: Tasks

DZone's Guide to

Automating Outlook With Ruby: Tasks

·
Free Resource
From the Ruby on Windows blog...

require 'win32ole'

outlook = WIN32OLE.new('Outlook.Application')

#   creating a new task
task = outlook.CreateItem(3)
task.Subject = 'Order Yankees Playoff Tickets'
task.Body = 'Order first-round playoff tickets...'
task.ReminderSet = true
task.ReminderTime = '07/19/2007 9:00 AM'
task.DueDate = '07/20/2007'
task.ReminderPlaySound = true
task.ReminderSoundFile = 'C:\Windows\Media\Ding.wav'
task.Save

#   getting tasks data
mapi = outlook.GetNameSpace('MAPI')
tasks = mapi.GetDefaultFolder(13)
for task in tasks.Items.Restrict("[Status] = 'Waiting on someone else'")
    puts task.Subject
    puts task.DueDate
    puts task.PercentComplete
    puts task.Status
    puts task.Importance
    puts task.LastModificationTime
end

#   search for and delete tasks
for task in tasks.Items.Restrict("[Subject] = 'Order Yankees Playoff Tickets'")
    task.Delete
end

Further details can be found here.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}