none
Advance query search, wrong mails returned - XML RRS feed

  • Question

  • Hi,

    I am using the advance query string to get mails from a mailbox but it doesn't work properly.

    Edit : I am using XML to perform my requests, I cannot use C#.

    What I want is all mails that contain the string 'Facture:31' in their subject or body (there is 5 more numbers after the 31). Here is my request <NS3:QueryString>Subject:Facture:31 OR Body:Facture:31</NS3:QueryString>

    What I get is mail with 'Facture:31' but also some mail without this string in their subject or body (I have of course checked). What is strange is if I add one more number (eg. 'Facture:315'), I don't recover the wrong the mail anymore (only the expected one). But it is not a solution to add one number (for previous and external development reason). I also found that it is the Body condition that retrieve wrong information (but I cannot change that for the same reason).

    Maybe the problem is due to the colon ? So is there a way to escape it? And a way to escape all special character (for example + or -)

    About the wrong mails : they all contain Facture: but another number (they all begin with 10) and they all have been forwarded (subject begin with FW: Facture:10...).

    Please note that I also try with the search filters but the same problem occurs (wrong mails returned) and all mails recent are not directly available due to the indexation that take some time.

    Thanks a lot for helping me :)


    • Edited by EVenturaB Friday, January 22, 2016 10:34 AM
    Monday, January 11, 2016 8:26 AM

All replies

  • $query = 'Subject:{0} OR Body:{1}' -f $($Subjectquery),$($bodyquery)

    This is what I had to do when writing my 'Search-Mailbox' program. Hope it helps.

    Monday, January 11, 2016 7:26 PM
  • A few things you could try is first just try a query without specifying KeyWord/Value  eg

            </m:ParentFolderIds>
            <m:QueryString>'Fracture:31'</m:QueryString>
          </m:FindItem>

    That will search on all indexed properties.

    Another thing is with this query and your other queries is make sure you use single quotes to encase your query as that will ensure the : is escaped, (All AQS queries are substrings anyway). I would always recommend you check/expect some false positive matches so you should always be doing client side filtering to double check the result.

    Cheers
    Glen

    Tuesday, January 12, 2016 3:07 AM
  • Hi Glen,

    Here are some other tests :

    <NS3:QueryString>'Facture:31'</NS3:QueryString> : return only the wrong mails

    <NS3:QueryString>Subject:'Facture:31' OR Body:'Facture:31'</NS3:QueryString> :  return only the wrong mails.

    About your recommendation, do you have an idea why the QueryString is not reliable? I don't understand why the behavior is not the same for the search in the subject and in the body.

    For the ignore of the - and +, i created a function that replace any " + " or " - " by a blank and it works as expected.

    I suppose I will have to keep it like that because we don't recover the body of the mail through this operation and as far as I know, it works like that. I will suggest to move the wrong mail in another folder, like that they will not be recovered anymore.

    Thanks for your help

    Thursday, January 14, 2016 9:29 AM
  • Hi Josh,

    It doesn't work for me, to be exact, it returns only the wrong mails...

    Thursday, January 14, 2016 9:30 AM