首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何按日期迭代Outlook收件箱?- Outlook OLE自动化

如何按日期迭代Outlook收件箱?- Outlook OLE自动化
EN

Stack Overflow用户
提问于 2010-07-21 09:51:24
回答 1查看 3.1K关注 0票数 0

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

我发现了一些有用的信息here,但收件箱中的消息顺序并不是按RecevedTime(项OLE对象的属性)排序的。GetLast方法可能会找到最新的消息,但是GetPrevious方法不能像我预期的那样工作。

代码语言:javascript
运行
复制
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?

如何从最新到最旧迭代收件箱中的邮件?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-05 16:44:32

代码语言:javascript
运行
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3295772

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档