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?

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,323 questions
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.