0

我想迭代 Outlook 收件箱,我正在使用 Ruby。

我在这里找到了一些有用的信息,但收件箱中的消息顺序不是按 RecevedTime(Item OLE 对象的属性)排序的。GetLast 方法可能会找到最新消息,但 GetPrevious 方法无法按预期工作。

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?

如何将收件箱中的消息从最新到最旧迭代?

4

1 回答 1

0
require 'win32ole'

ol = WIN32OLE.new('Outlook.Application')
class OC; end
WIN32OLE.const_load(ol, OC)

mapi = ol.GetNameSpace("MAPI")
inbox = mapi.GetDefaultFolder(OC::OlFolderInbox)
items = inbox.items
items.sort('ReceivedTime', OC::OlAscending)

items.getfirst
items.getnext

items.getlast
items.getprevious
于 2011-01-05T08:44:32.190 回答