在适用于 2003、2007 和 2010 年的 Outlook 上执行编程式发送/接收
我正在尝试编写一些支持 Outlook 2003、2007 和 2010 的基本 Outlook 代码。我正在使用 Outlook 2010 PIA。除了导致 Outlook 执行发送/接收的方法之外,一切正常。我尝试了几个选项:
- 调用 Namespace.SendAndReceive 方法(适用于 Outlook 2007 和 2010,在 Outlook 2003 上失败并出现 AccessViolationException)。
- 迭代 Namespace.SyncObjects 并调用其启动方法(适用于 Outlook 2003 和 2007,但在 Outlook 2010 上失败,当我尝试在应用程序对象上调用 GetNamespace("MAPI") 时,RPC 服务器不可用)
有人可以提出一种方法吗?应该在所有版本上一致工作?
I am trying to write some basic Outlook code that should support Outlook 2003, 2007 and 2010. I am working with Outlook 2010 PIAs. Everything works except a method that should cause Outlook to perform Send/Receive. I have tried a couple of options:
- Call Namespace.SendAndReceive method (works on Outlook 2007 and 2010, fails on Outlook 2003 with AccessViolationException).
- Iterate through Namespace.SyncObjects and calling their start method (works in Outlook 2003 and 2007 and fails on Outlook 2010 with RPC server is not available when I try to call GetNamespace("MAPI") on my application object)
Can someone propose a method that should work consistently on all versions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信
SendAndReceive()
是在 2007 年作为一种便捷方法添加的,因此正如您发现的那样,它在 2003 年不起作用。根据 2010 文档,您应该仍然可以使用SyncObjects
集合并仍然调用Start()
。您的 2010 年安装是否有可能包含错误的邮件/新闻/其他配置文件?Start()
是否在特定SyncObject
上失败?您可能已经想到的另一个解决方案是在 2003 版本中使用
SyncObjects
,在未来版本中使用SendAndReceive()
。I believe that
SendAndReceive()
was added as a convenience method in 2007 so that won't work in 2003 as you found out. According to the 2010 documentation you should still be able to useSyncObjects
collection and still callStart()
. Is it possible that you're 2010 installation has a bad mail/news/whatever profile? IsStart()
failing on a specificSyncObject
?The other solution which you probably already thought of is to use
SyncObjects
for 2003 andSendAndReceive()
for future versions.