views:

15

answers:

0

I'd like to iterate Outlook Inbox and I'm with Ruby.

I've found some useful info here, but the order of message in Inbox is not ordered by RecevedTime(Property for Item OLE object). GetLast method may find the latest message but GetPrevious method does not work as I expected.

require 'win32ole'

outlook = WIN32OLE.new('Outlook.Application')
mapi    = outlook.GetNameSpace('MAPI')
inbox   = mapi.GetDefaultFolder(6)

inbox.Items.GetLast # return the latest message, maybe
inbox.Items.GetPrevious # return nil object and then, what's this method for?
inbox.Items.Sort('ReceivedTime')    # is this right usage? if so, what's next?

How can I iterate messages in Inbox from the latest to the oldest?