当 Outlook 2016 使用缓存 Exchange 模式时,GetExchangeUser() returns null
GetExchangeUser() returns null when Outlook 2016 uses Cached Exchange Mode
开发:Outlook 2016
加载项:VSTO (C#)
我的公司 运行 在 O365 (Exchange) 上,我正在开发一个插件来收集他们的交换用户信息并做各种事情。但是,当 Outlook 帐户设置配置为启用缓存 Exchange 模式时,似乎 GetExchangeUser() returns null.
如果我禁用客户端缓存 Exchange 模式,一切正常。但是我的公司希望保持启用此功能。
我的粗略理解是 GetExchangeUser() 只有在连接到 Exchange Server 时才有效。我怀疑缓存模式导致情况并非一直如此,因此该方法失败。所以我想知道..
- 我如何强制(暂时)Outlook 连接到 Exchange 以便 GetExchangeUser() 工作?
是否有其他收集 Exchange 用户信息的方法?
// 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;
我已经尝试了一些我在网上找到的建议,其中 none 行得通。比如..
- 强制更新脱机通讯簿(不起作用)。
- 删除旧的脱机通讯簿然后强制更新(不起作用)。
请记住,ExchangeUser
对象(从 AddressEntry.GetExchangeUser()
返回)不会公开您无法从 AddressEntry.PropertyAccessort.GetProperty()
获得的任何内容。
验证数据是否确实存在 - 您可以从 OutlookSpy(我是其作者)执行此操作:单击 OutlookSpy 功能区上的命名空间按钮。展开 CurrentUser 属性,展开 AddressEntry,select MAPIOBJECT 属性,单击“浏览”。在 IMailUser window 中,您是否看到了所需的所有 MAPI 属性?如果您 select a 属性,OutlookSpy 将显示其 DASL 名称。您可以在调用 AddressEntry.PropertyAccessort.GetProperty()
.
时使用该 DASL 属性 名称
开发:Outlook 2016 加载项:VSTO (C#)
我的公司 运行 在 O365 (Exchange) 上,我正在开发一个插件来收集他们的交换用户信息并做各种事情。但是,当 Outlook 帐户设置配置为启用缓存 Exchange 模式时,似乎 GetExchangeUser() returns null.
如果我禁用客户端缓存 Exchange 模式,一切正常。但是我的公司希望保持启用此功能。
我的粗略理解是 GetExchangeUser() 只有在连接到 Exchange Server 时才有效。我怀疑缓存模式导致情况并非一直如此,因此该方法失败。所以我想知道..
- 我如何强制(暂时)Outlook 连接到 Exchange 以便 GetExchangeUser() 工作?
是否有其他收集 Exchange 用户信息的方法?
// 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;
我已经尝试了一些我在网上找到的建议,其中 none 行得通。比如..
- 强制更新脱机通讯簿(不起作用)。
- 删除旧的脱机通讯簿然后强制更新(不起作用)。
请记住,ExchangeUser
对象(从 AddressEntry.GetExchangeUser()
返回)不会公开您无法从 AddressEntry.PropertyAccessort.GetProperty()
获得的任何内容。
验证数据是否确实存在 - 您可以从 OutlookSpy(我是其作者)执行此操作:单击 OutlookSpy 功能区上的命名空间按钮。展开 CurrentUser 属性,展开 AddressEntry,select MAPIOBJECT 属性,单击“浏览”。在 IMailUser window 中,您是否看到了所需的所有 MAPI 属性?如果您 select a 属性,OutlookSpy 将显示其 DASL 名称。您可以在调用 AddressEntry.PropertyAccessort.GetProperty()
.