locked
Powershell Outook advancedsearch. Name of folder for found message. RRS feed

  • Question

  • So i have a very basic search that works really well. However I really need to know where the email is within the mailbox structure (eg \inbox\ebs\sandra) 

    $Term  = 'pheno-geno'
    $Scope = "'\'"
     

    $Outlook = New-Object -ComObject Outlook.Application
    $Emails  = $Outlook.AdvancedSearch( $Scope, "urn:schemas:httpmail:textdescription LIKE '%$Term%'", $true)

    Start-Sleep -Seconds 10

    $Emails.Results | Select-Object 



    • Edited by Joe Darkman Thursday, July 23, 2020 1:34 PM
    Thursday, July 23, 2020 1:32 PM

All replies

  • Oh my giddy aunt, I am a silly.

    foreach ($searchResult in $Emails.Results)
    {    Write-Host $searchResult.Parent.FolderPath
    }


    Thursday, July 23, 2020 1:47 PM
  • I am very glad that you can find the problem by yourself.

    If your problem has been solved, please mark it as an answer.

    :)


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, July 28, 2020 5:26 AM
  • Hi,
    As this thread has been quiet for a while, so here is a quick question.Was your issue resolved? 
    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.
    Best Regards,
    Yang Yang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, July 28, 2020 7:28 AM