myFolder.CurrentView may return the wrong view
Developing an Outlook add-in that modifies the CurrentView
of folders while switching folders in Outlook has led to an unexpected issue.
We retrieve the CurrentView
of a folder as follows:
Outlook.Folder myFolder = Application.ActiveExplorer().CurrentFolder as Outlook.Folder;
Outlook.TableView myView = myFolder.CurrentView;
Typically, myView
returns the correct view of the folder, but in certain rare instances, it returns the view from the previous folder before switching.
For example:
- Folder = Inbox, View = View1
- Folder = Sent Items, View = View2
When switching from Sent Items to Inbox, myFolder
points to Inbox, but myView
retrieved may return View2.
What could be causing this behavior? Would introducing a delay of one or two seconds after switching folders and before reading the CurrentView
be beneficial?