none
Searching items in PST RRS feed

  • Question

  • Hi There,

                  I want to understand how Outlook Search works. There are property tags like

    PR_SEARCH_FLAGS,   PR_IPM_SENTMAIL_SEARCH_KEY,   PR_SEARCH_Key

    Are these tags used in search keywords within PST file? How can I programmatically search a mail given a  search text\date range? Kindly advice.
    Friday, November 29, 2013 10:01 AM

Answers

  • Hi Jude_BigJ,

    The Outlook Object Model can be used for searching within the body of e-mails (not attachments).

    The advanced search can also be used (not only Find/FindNext/Restrict as Dmitry wrote). You can read more about this in the Advanced search in Outlook programmatically: C#, VB.NET article.

    The key benefits of using the AdvancedSearch method in Outlook are:

    • The search is performed in another thread. You don’t need to run another thread manually since the AdvancedSearch method runs it automatically in the background.
    • Possibility to search for any item types: mail, appointment, calendar, notes etc. in any location, i.e. beyond the scope of a certain folder. The Restrict and Find/FindNext methods can be applied to a particular Items collection (see the Items property of the Folder class in Outlook).
    • Full support for DASL queries (custom properties can be used for searching too). You can read more about this in the Filtering article in MSDN. To improve the search performance, Instant Search keywords can be used if Instant Search is enabled for the store (see the IsInstantSearchEnabled property of the Store class).
    • Finally, you can stop the search process at any moment using the Stop method of the Search class.


    Monday, December 2, 2013 6:08 AM

All replies

  • Hi Jude_BigJ,

    Why do you need to use Extended MAPI or any other technologies for searching in Outlook pst? The Outlook Object Model provides all the required classes to get the job done. Please take a look at the Advanced search in Outlook programmatically: C#, VB.NET article.




    Friday, November 29, 2013 10:09 AM
  • Thanks for the quick reply,

                       I will give it a try, Does the sample code require Outlook to be installed on your machine?

    Friday, November 29, 2013 10:19 AM
  • Yes, it does. Frankly speaking, the Extended MAPI engine will not work until you install the standalone version of MAPI or Outlook.  
    Friday, November 29, 2013 10:32 AM
  • Given that PST format is known, I was thinking of reading the PST file in raw, So was wondering what Outlook might be doing to search PST file, do you have any idea about which property tags might be used for search

    PR_SEARCH_FLAGS,   PR_IPM_SENTMAIL_SEARCH_KEY,   PR_SEARCH_Key

    The above PropertyTags have "Search" in their names, are they used for searching in PST file?

    Friday, November 29, 2013 10:39 AM
  • I don't think I have ever seen PR_SEARCH_FLAGS. Where are you seeing it?

    What exactly are you trying to do and why?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, November 29, 2013 4:58 PM
  • Hi Jude_BigJ,

    Actually, none of them was used by me. The Outlook Object Model provides all the required classes for such task. Moreover, I didn't find any description for these property tags in MSDN. 

    Friday, November 29, 2013 7:54 PM
  • I want to be able to search emails based on their properties(to,subject, body attachment content etc) without manually indexing them and preferably without outlook installed in the machine.
    Saturday, November 30, 2013 1:32 PM
  • If you want to read the PST files without Outlook installed, you have no choice but to parse the PST files - the format is documented at http://msdn.microsoft.com/en-us/library/ff385210(v=office.12).aspx

    Otherwise you can either use the Outlook Object Model (Namespace.AddStore/AddStoreEx to open a PST file, then MAPIFolder.Items.Find/FindNext/Restrict to search) or Extended MAPI (C++ or Delphi) only. The latter approach does not require to add PST file to a profile that the user might be already using. If Redemption is an option, you can also use RDOSession.LogonPstStore or RDOSession.Stores.AddPstStore to open PST files.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Saturday, November 30, 2013 6:27 PM
  • Just as a FYI - the three props listed are part of an open source "OpenChange" project which is all I know about them <g>. All the Mapi props included in this project are listed in the link below

    MAPI Implementation
    OpenChange Project
    http://anonsvn.wireshark.org/wireshark/trunk/epan/dissectors/pidl/mapi/mapitags_enum.h


    Karl Timmermans [Outlook MVP] "Outlook Contact Import/Export/Data Mgmt" http://www.contactgenie.com

    Monday, December 2, 2013 2:39 AM
  • >>Otherwise you can either use the Outlook Object Model (Namespace.AddStore/AddStoreEx to open a PST file, >> then MAPIFolder.Items.Find/FindNext/Restrict to search) 

    Does the Outlook object model allows you to search within body of mail or contents of attachment?


    Monday, December 2, 2013 5:57 AM
  • You can search within the message body/subject/etc. using Items.Find/FindNext/Restrict. But you cannot search within the attachment data. You would need to use Windows Search for that.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, December 2, 2013 6:06 AM
  • Hi Jude_BigJ,

    The Outlook Object Model can be used for searching within the body of e-mails (not attachments).

    The advanced search can also be used (not only Find/FindNext/Restrict as Dmitry wrote). You can read more about this in the Advanced search in Outlook programmatically: C#, VB.NET article.

    The key benefits of using the AdvancedSearch method in Outlook are:

    • The search is performed in another thread. You don’t need to run another thread manually since the AdvancedSearch method runs it automatically in the background.
    • Possibility to search for any item types: mail, appointment, calendar, notes etc. in any location, i.e. beyond the scope of a certain folder. The Restrict and Find/FindNext methods can be applied to a particular Items collection (see the Items property of the Folder class in Outlook).
    • Full support for DASL queries (custom properties can be used for searching too). You can read more about this in the Filtering article in MSDN. To improve the search performance, Instant Search keywords can be used if Instant Search is enabled for the store (see the IsInstantSearchEnabled property of the Store class).
    • Finally, you can stop the search process at any moment using the Stop method of the Search class.


    Monday, December 2, 2013 6:08 AM
  • Hi all, 

             I trying to implement Instance search in my app using outlook object model.I am facing some problems while adding some PST file to store.{"Outlook failed to add the personal store to this session"} this exception is occuring while adding some PST files in the current namespace of outlook app.

    here is code,

                    ns = OutlookApp.GetNamespace("MAPI");
                    try
                    {
                        ns.AddStore(f_objSearhItemsForFilters.f_strPstFilePath);
                       //ns.AddStoreEx(f_objSearhItemsForFilters, OlStoreType.olStoreDefault);
                    }
                    catch (System.Exception Ex)
                    {
                    }

    Is there any solution for this ? Kindly advice.


        


    H.S.Navarkar

    Tuesday, December 10, 2013 7:02 AM