2010-07-21 54 views
0

我想迭代Outlook收件箱,我与Ruby。如何迭代Outlook收件箱的日期? - Outlook OLE自动化

我发现一些有用的信息here,但收件箱中的邮件顺序不是按照RecevedTime(Item for OLE object的属性)排序的。 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? 

如何在Inbox中将邮件从最新到最旧?

回答

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 
相关问题