Using Outlook Search to enumerate folders

Add-in Express™ Support Service
That's what is more important than anything else

Using Outlook Search to enumerate folders
 
Sam Vaynshtok


Guest


We need to enumerate Outlook folders containing particular items - Tasks, Appointments and/or Contacts.
Currently we do recursive navigation checking if folder contains any items of given type.
I would prefer to use Outlook Search instead. However, all examples I saw are dealing with items, not folders. Is there a way to do this?

Thanks,

Sam
Posted 11 Apr, 2014 14:52:04 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Sam,

The Search Folders feature is about items, not folders. Here's a citation from from http://office.microsoft.com/en-001/outlook-help/create-a-search-folder-HA010038911.aspx:

A Search Folder is a virtual folder that provides a view of all e-mail items that match specific search criteria. For example, the Unread Mail Search Folder allows you to view all unread messages from one location even though the messages may be located in different Mail folders.


In Programming Applications for Microsoft Office Outlook 2007, they write that search folders are supported for items in mail folders. That is, you cannot use a search folder to find e.g. all tasks and the use TaskItem.Contact to find the folders.

Sam Vaynshtok writes:
Currently we do recursive navigation checking if folder contains any items of given type.


You can check MAPIFolder.DefaultItemType instead. This isn't a 100% thing however: you may move any item to any folder.


Andrei Smolin
Add-in Express Team Leader
Posted 14 Apr, 2014 04:40:41 Top
Sam Vaynshtok


Guest


I know about DefaultItemType, but you already mention the issue with it.

Thanks,
Sam
Posted 14 Apr, 2014 07:57:49 Top