none
Exception Calling "AdvancedSearch with outlook.application and MAPI RRS feed

  • Question

  • Hello Scripting Guys!, This is my first question but I read you frequently.

    I wrote a script to "datamining" information from my outlook mail client folders and mails and it was running ok but I want  improve the performance.To try do this I was testing the AdvancedSearch method from Microsoft.Office.Interop.Outlook.ApplicationClass to try use DSL with it. But I have found the next error when I invoke the method:

    Exception calling "AdvancedSearch" with "4" argument(s): "Could not complete the operation. One or more parameter values are not valid."
    At <path to my test script>:<line with AdvancedSearch method> char:1
    + $s=$o.AdvancedSearch($Scope,$Filter,$true,'Test')
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ArgumentException

    I tried use [ref] with my parameters and later use directly the values in the call without success. I tried a simple call to test and I obtain the same error:

    $o=New-Object -comobject outlook.application

    $n = $o.GetNamespace('MAPI')

    $Scope= "\test@mail.com\Inbox\TEST\"

    $Filter="urn:schemas:httpmail:subject='/var/tomcat/scripfiles/test'"

    $s=$o.AdvancedSearch($Scope,$Filter,$true,'TestTag')

    $s.Results

    Any idea that how I could use this method on Powershell?. 

    Thank you in advance for your help and time with this.


    • Moved by Bill_Stewart Tuesday, March 1, 2016 11:58 PM Move to more appropriate forum
    Friday, January 15, 2016 12:00 PM

All replies

  • Scope needs to be enclosed in single quotes:

    $Scope= "'\test@mail.com\Inbox\TEST\'"


    \_(ツ)_/

    Friday, January 15, 2016 12:11 PM
  • Thank you a lot jrv. I tested using you Scope configuration but the result was the same that previous times. I tried separate the fields in scope using "," character and creating only one string but again the same error. In the filter I tried add the "@SQL=" and concatenate using "\'" with the "urn" but never I could avoid the mentioned error.

    Do you know other causes that could be generating this error?

    Thank you in Advance for help!


    Monday, January 18, 2016 5:00 PM
  • Scope is a single folder enclosed in single quotes.

    $Scope= "  ' \test@mail.com\Inbox\TEST\ ' "

    Notice single quotes.  The folder must be the store plus the folder path.



    \_(ツ)_/

    Monday, January 18, 2016 5:04 PM
  • Hi Chema81,

    Some parameters are optional, please try to remove some parameters and try again.

    Do you have the same issue when you try it with VBA code directly?

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 4, 2016 5:04 AM
    Moderator