我想迭代Outlook收件箱,我使用Ruby。
我发现了一些有用的信息here,但收件箱中的消息顺序并不是按RecevedTime(项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?
如何从最新到最旧迭代收件箱中的邮件?
发布于 2011-01-05 16:44:32
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
https://stackoverflow.com/questions/3295772
复制相似问题