question

FionaYuan-6378 avatar image
0 Votes"
FionaYuan-6378 asked JadeLiang-MSFT edited

Powershell: Outlook advanced search default sort order

Hello,
My environment:
Win10/Powershell 5.0/Outlook 365
I'm pulling history emails from an outlook folder. I got around 35K emails.
I tried to dump them to a .csv file using below command:
$query = "important notification"
$filter = "urn:schemas:httpmail:subject LIKE '%"+$query+"%'"
$search = $outlook.AdvancedSearch("'$scope'", $filter, $true)
....(event registered to capture the result)
$mails = $search.results
$mails | Select-Object -Property Subject, ReceivedTime,body | export-csv -append -Path $filename -NoTypeInformation

Then I got an outlook out of memory error, then nothing will be in the "body" field.

I tried to slice the $mails to smaller arrays but after some iterations I got the same result - at around the #15~16K records. And it can only be resolved by restart outlook on my PC.

My questions are:
1) Is there a configuration item i can use to avoid the problem? i.e. increase the memory allocation to outlook?
2) If item 1) is unavailable, what's the default sort order of the advanced search result? As I have partial result in the output file, I can pick up from there
I tried to sort the $mails by the receivedTime but I also got out of memory issue as there are 35K results...
Thanks

windows-server-powershell
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @FionaYuan-6378,
Welcome to our forum.
Please understand under Outlook tag, we mainly focus on general issue on Outlook desktop client Considering your issue may be more related to powershell, I would remove Outlook tag under your post, thanks for your understanding and hope your issue would be resolved soon.

0 Votes 0 ·

0 Answers