Developing for: Outlook 2016 Add-In: VSTO (C#)
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.
If I disable the clients Cached Exchange Mode everything works fine. However my company wants to keep this feature enabled.
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 ..
- 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 ..
- Force a Offline Address book update (Doesn't work).
- Delete the old Offline Address Book then force an update (Doesn't work).