'How to differentiate Outlook folders to return visible folders only?
I pull the Outlook (365, Exchange server) folders like this:
Dim otkApp As Outlook.Application = New Outlook.Application
Dim otkNameSpace As Outlook.NameSpace = otkApp.GetNamespace("MAPI")
Dim folders = otkNameSpace.Folders
This gets me several additional folders along with those that I see in the Outlook app. For example, I get "Sync Issues", "Quick Step Settings" and "Conversation Action Settings".
How can I remove those folders?
I don't see any property that is different than those at "Inbox" folder. I remove only some of them with a check .DefaultMessageClass = "IPM.Note"
.
Edit (based on an Dmitry's answer):
Dim prop As Boolean = False
Try
prop = subfolder.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10F4000B")
Catch ex As System.Exception
prop = False
End Try
If prop Or Not subfolder.DefaultMessageClass = "IPM.Note" Then
Continue For
End If
This gets rid of most of those folders, but "Sync Issues" remains.
Solution 1:[1]
You can skip the folders with PR_ATTR_HIDDEN
MAPI property == true. The property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x10F4000B"
) can be accessed using MAPIFolder.PropertyAccessor.GetProperty
. You can see that property in OutlookSpy (I am its author) - click IMAPIFolder button.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |