c# - How to retrieve a list of all custom folders in Outlook containing only MailItems? -
i attempting retrieve list of custom folders created user such can global advanced search. want custom folders mailitems objects contained within them, want exclude several folders list (e.g. rss feeds, quick step settings, suggested contacts) come standard in outlook store.
first, question similiar questions asked below, selected answers did not address custom folders--just folders.
does know how retireve list of custom folders contain mailitem objects? have created large if block filter out unwanted folders, need more generic approach since deployed on user computers , who-knows-what people outlook folders?
if ( // remove specific search folders cope subfolder.name == "quick step settings" || subfolder.name == "news feed" || subfolder.name == "conversation history" || subfolder.name == "conversation action settings" || // remove unwanted default folders returning expiring items subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfoldercalendar).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderconflicts).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfoldercontacts).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderdeleteditems).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderjournal).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderrssfeeds).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfoldersuggestedcontacts).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfoldersyncissues).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderserverfailures).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderjunk).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfolderlocalfailures).folderpath || subfolder.folderpath == globals.thisaddin.application.session.getdefaultfolder(outlook.oldefaultfolders.olfoldertasks).folderpath || // eliminate custom folders unwanted default types subfolder.defaultitemtype == outlook.olitemtype.olcontactitem || subfolder.defaultitemtype == outlook.olitemtype.oljournalitem || subfolder.defaultitemtype == outlook.olitemtype.olappointmentitem || subfolder.defaultitemtype == outlook.olitemtype.oldistributionlistitem || subfolder.defaultitemtype == outlook.olitemtype.oldistributionlistitem ) { addfolder = false; }
you need recursively loop through folders starting namespace.folders. each folder, check defaultitemtype property. if want exclude default mail folders (such inbox , sent items), compare folder's entry with entry id of default folders retrieved getdefaultfolder.
Comments
Post a Comment