当 Outlook 2016 使用缓存 Exchange 模式时,GetExchangeUser() 返回 null [英] GetExchangeUser() returns null when Outlook 2016 uses Cached Exchange Mode

查看:36
本文介绍了当 Outlook 2016 使用缓存 Exchange 模式时,GetExchangeUser() 返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开发:展望 2016插件:VSTO (C#)

Developing for: Outlook 2016 Add-In: VSTO (C#)

我的公司在 O365 (Exchange) 上运行,我正在开发一个加载项,用于收集他们的 Exchange 用户信息并执行各种操作.但是,当 Outlook 帐户设置配置为启用缓存 Exchange 模式时,GetExchangeUser() 似乎返回 null.

My company is running on O365 (Exchange) and I am developing an add-in which collects their exchange user information and does various things. However, it appears that when the Outlook Account Settings is configured with Cached Exchange Mode enabled the GetExchangeUser() returns null.

如果我禁用客户端缓存 Exchange 模式,一切正常.但是,我的公司希望保持启用此功能.

If I disable the clients Cached Exchange Mode everything works fine. However my company wants to keep this feature enabled.

我的粗略理解是 GetExchangeUser() 仅在连接到 Exchange Server 时才有效.我怀疑缓存模式导致这种情况并非一直如此,因此该方法失败.所以我想知道..

My rough understanding is that GetExchangeUser() only works when connected to the Exchange Server. I suspect that the Cached mode causes this not to be the case all the time and therefore the method fails. So I'm wondering ..

  • 如何强制(临时)Outlook 连接到 Exchange 以便 GetExchangeUser() 正常工作?
  • 是否有其他收集 Exchange 用户信息的方法?

  • How can I force (temporarily) Outlook to connect to Exchange so that GetExchangeUser() works?
  • Are there any alternative ways of collecting the Exchange user information?

// Create a singleton of the Application instance.
Outlook.Application app = new Outlook.Application();

// Get the current user object.
Outlook.ExchangeUser currentUser = app.Session.CurrentUser.AddressEntry.GetExchangeUser();

// ***** currentUser == null when "Use Cached Exchange Mode" is enabled.
// ***** currentUser == Outlook.ExchangeUser object when "Use Cached Exchange Mode" is disabled.

// Set the form details.
textBoxName.Text = currentUser.Name;
textBoxEmployeeID.Text = currentUser.Alias;

我尝试了许多在网上找到的建议,但都没有奏效.比如..

I have tried a number of suggestions I've found online, none of them have worked. Such as ..

  • 强制离线通讯簿更新(不起作用).
  • 删除旧的离线通讯簿,然后强制更新(不起作用).

推荐答案

记住 ExchageUser 对象(从 AddressEntry.GetExchageUser() 返回)不会暴露任何东西您无法从 AddressEntry.PropertyAccessort.GetProperty() 获取.

Keep in mind that ExchageUser object (returned from AddressEntry.GetExchageUser()) does not expose anything you cannot get from AddressEntry.PropertyAccessort.GetProperty().

验证数据是否确实存在 - 您可以从 OutlookSpy 执行此操作:单击命名空间按钮在 OutlookSpy 功能区上.展开 CurrentUser 属性,展开 AddressEntry,选择 MAPIOBJECT 属性,单击浏览".在 IMailUser 窗口中,您是否看到了您需要的所有 MAPI 属性?如果您选择一个属性,OutlookSpy 将显示其 DASL 名称.您可以在调用 AddressEntry.PropertyAccessort.GetProperty() 时使用该 DASL 属性名称.

Verify that the data is actually there - you can do that from OutlookSpy: click Namespace button on the OutlookSpy ribbon. Expand CurrentUser property, expand AddressEntry, select MAPIOBJECT property, click "Browse". In the IMailUser window, do you see all the MAPI properties that you need? If you select a property, OutlookSpy will show its DASL name. You can use that DASL property name when calling AddressEntry.PropertyAccessort.GetProperty().

这篇关于当 Outlook 2016 使用缓存 Exchange 模式时,GetExchangeUser() 返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆