myFolder.CurrentView may return the wrong view

Lawrence Wong 0 Reputation points
2025-01-16T02:01:28.76+00:00

We are developing an Outlook add-in which modify the CurrentView of folders when switching folders in Outlook.

However, we noticed a weird problem.

We retrieved the CurrentView of a folder roughly by:

Outlook.Folder myFolder = Application.ActiveExplorer().CurrentFolder as Outlook.Folder;

Outlook.TableView myView = myFolder.CurrentView;

Normally, the myView returns the correct view of the folder, but in some rare cases, it returns the view of the previous folder before switching.

E.g.

Folder = Inbox, View = View1

Folder = Sent Items, View = View2

When switching from Sent Items to Inbox, myFolder is Inbox, but myView retrieved may become View2.

How is this possible?

Will it help if we add one or two seconds of delay after switching folder and before reading the CurrentView?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
Outlook
Outlook
A family of Microsoft email and calendar products.
4,503 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,334 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hornblower409-4652 80 Reputation points
    2025-01-16T06:34:40.6866667+00:00

    Explorer.CurrentView property

    "To obtain a View object for the view of the current Explorer, use Explorer.CurrentView instead of the CurrentView property of the current Folder object returned by Explorer.CurrentFolder."

    0 comments No comments

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.