myFolder.CurrentView may return the wrong view

Lawrence Wong 0 Reputation points
2025-01-16T04:07:10.57+00:00

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?

Microsoft 365 and Office | Development | Other
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.