Home > front end >  How to differentiate Outlook folders to return visible folders only?
How to differentiate Outlook folders to return visible folders only?

Time:10-11

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".
debug

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.

CodePudding user response:

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 (click IMAPIFolder button).

  • Related