none
Finding Outlook.Items Parent Folder Name During AdvanceSearch using Outlook object library RRS feed

  • Question

  • Hi all,

            I am using Advance Search feature of Outlook.Application Class using Outlook Object library.I am able to get results firing DASL querry with providing input scope of folder to Advance Search Method.Now I want to Get the Folder name where the current Outlook.ItemFound .I googled for this but coudnt find solution. please advice.

    Thanks,

    Hemant


    H.S.Navarkar

    Monday, February 10, 2014 7:36 AM

Answers

  • If you're handling the AdvancedSearchComplete() event, as you should, you get a Search object passed to you in the event. You can use Search.Results to get a Results collection and iterate it.

    Each item in the Results collection can be checked for Parent, which is the folder whee the item is stored. Once you get the folder you can then get the Name property of the folder.


    Ken Slovak MVP - Outlook

    Monday, February 10, 2014 4:31 PM
    Moderator

All replies

  • Hello Hemant,

    First of all, please take a look at the Advanced search in Outlook programmatically: C#, VB.NET article. It explains the advanced search in depth and provides a sample code in C# and VB.NET.

    The Save method of the Search class from the Outlook object model allows you to save the search results to a Search Folder. Note, the method requires a string parameter which represents the Search folder name. The Save method returns an instance of the Folder class in which you are interested in. Actually, it doesn’t contain any items, only references to items from the scope folders are stored.

    Also you can use the GetSearchFolders method of the Store class to get a Folders collection object that represents the search folders defined for the Store object. Then you can find the required Search folder by its name specified for the Save method (described above).


    Monday, February 10, 2014 10:11 AM
  • If you're handling the AdvancedSearchComplete() event, as you should, you get a Search object passed to you in the event. You can use Search.Results to get a Results collection and iterate it.

    Each item in the Results collection can be checked for Parent, which is the folder whee the item is stored. Once you get the folder you can then get the Name property of the folder.


    Ken Slovak MVP - Outlook

    Monday, February 10, 2014 4:31 PM
    Moderator
  • Hi all,

            The problem get resolved.Thanks Ken for your advice it resolve my issue.As ken told i use typecasting on  the result item to corresponding Outlook.Item then i use Parent property on it to find Parent MAPI Folder of it and the use its ID to find information of the folder. 



    H.S.Navarkar

    Tuesday, February 11, 2014 6:41 AM