2010-07-21 5 views
0

Outlook받은 편지함을 반복하고 Ruby를 사용하고 싶습니다.Outlook받은 편지함을 날짜순으로 반복하는 방법은 무엇입니까? - Outlook OLE 자동화

유용한 정보 인 here을 찾았지만받은 편지함의 메시지 순서가 ReceivedTime (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? 

받은 편지함에서 가장 오래된 메시지부터 가장 오래된 메시지까지 반복 할 수있는 방법은 무엇입니까?

답변

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 
관련 문제