Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Automating Outlook with Ruby: Tasks (See related posts)

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.


You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts