none
Problem for searching Attachment as per content. RRS feed

  • Question

  • Hi All,

    I am facing other issue , I am  using DASL querry for  searching items in PST file using outlook object model (in c#).I am facing problem while searching  items on "attachment content filter".  here is code that i am using for finding attachment in Content filter .but every time no result is getting though the corresponding PST having attachment with search content.

    private void DemoSearchAttachments() 

        string filter; 
        conststring PR_SEARCH_ATTACHMENTS =  
            "http://schemas.microsoft.com/mapi/proptag/0x0EA5001E"; 
        if (Application.Session.DefaultStore.IsInstantSearchEnabled) 
        { 
            filter = "@SQL=" + "\"" 
                + PR_SEARCH_ATTACHMENTS + "\"" 
                + " ci_phrasematch 'office'"; 
            Outlook.Table table = Application.Session.GetDefaultFolder( 
                Outlook.OlDefaultFolders.olFolderInbox).GetTable( 
                filter, Outlook.OlTableContents.olUserItems); 
            while (!table.EndOfTable) 
            { 
                Outlook.Row row = table.GetNextRow(); 
                Debug.WriteLine(row["Subject"]); 
            } 
        } 
    }

    please Kindly advice,

    Thanks...


    H.S.Navarkar

    Friday, December 13, 2013 1:47 PM

Answers

  • If the store is just added, it will not be indexed, and PR_SEARCH_ATTACHMENTS can only used with an indexed store.

    The only (extremely inefficient) way is to loop through all messages with attachments, save attachments to disk, then process them explicitly. Of course that will not work with all file types unless you know ho to parse them - e.g. DOCX files are zipped, so you cannot blindly look for a string "office".

    Also keep in mind that you really need to use OlTableContents.olUserItems instead of OlTableContents.olHiddenItems - otherwise you will be searching through the associated (hidden) items, and chances are there aren't any in that folder.


    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 16, 2013 1:32 PM

All replies

  • Was the PST store already added to one of the Outlook profiles? Was it already indexed by Windows Search?


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

    Friday, December 13, 2013 1:57 PM
  • Hello Hemant,

    It looks like you are copied the code from the How to: Search Attachments of Items in a Folder for an Exact Phrase page in MSDN. Am I right?

    Do you have any attached files in the Inbox folder that contain the 'office' keyword?

    Friday, December 13, 2013 2:03 PM
  • Hi Eugene, 

                       The above code i found from the same link  and yes i have some attachment in my Inbox folders which having that keyword within it.is there any other way to search attachment on base of contents ?. will you also please tell me does ID of PropertySchemaName changes machine to machine ? or is it fixed.

          Kindly advice.

    Thanks..


    H.S.Navarkar

    Monday, December 16, 2013 12:25 PM
  • Hi Dmitry,

                   No the PST file is not already added to store and also it is not indexed in windows search.The tool basically adding  .pst to current namespace store. and after getting Root folder on currently added store and then calling GetTable(filter, Outlook.OlTableContents.olHiddenItems) method on the MAPI object.But every time Outlook.Table.EndOfTable  comes true.

    Kindly Advice,



    H.S.Navarkar

    Monday, December 16, 2013 12:42 PM
  • If the store is just added, it will not be indexed, and PR_SEARCH_ATTACHMENTS can only used with an indexed store.

    The only (extremely inefficient) way is to loop through all messages with attachments, save attachments to disk, then process them explicitly. Of course that will not work with all file types unless you know ho to parse them - e.g. DOCX files are zipped, so you cannot blindly look for a string "office".

    Also keep in mind that you really need to use OlTableContents.olUserItems instead of OlTableContents.olHiddenItems - otherwise you will be searching through the associated (hidden) items, and chances are there aren't any in that folder.


    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 16, 2013 1:32 PM
  • The DASL property tag is fixed, it can be used on any machine. However, as Dmitry said you cannot use that property unless the store is indexed, otherwise you won't get the results you want.

    Ken Slovak MVP - Outlook

    Monday, December 16, 2013 2:53 PM
    Moderator
  • Hi Hemant,

    The property tag (a standard one) will be the same on all machines (if it is not a custom property).

    Monday, December 16, 2013 3:01 PM