Closed jrouzies-fr closed 1 year ago
$ItemView= New-Object Microsoft.Exchange.WebServices.Data.FolderView( 1000)
Shouldn't this be
$ItemView= New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)
(FolderView vs ItemView)
full example courtesy of ChatGPT:
# Set up the EWS service
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1)
$service.Credentials = New-Object System.Net.NetworkCredential("username", "password")
$service.Url = new-object Uri("https://outlook.office365.com/EWS/Exchange.asmx")
# Set up the search criteria
$folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox)
$itemView = new-object Microsoft.Exchange.WebServices.Data.ItemView(10)
$searchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::Subject, "ews")
# Search for items
$findResults = $service.FindItems($folderId, $searchFilter, $itemView)
# Loop through the results and print the subject of each item
foreach ($item in $findResults.Items) {
Write-Output $item.Subject
}
Oh my god you are right ... copy pasted the code from a script and didn't notice this.
Thanks, I'm closing the issue, sorry for that.
Hello,
I am trying to use EWS to clear some user contact cache he has that doesn't want to go away even with the clear on Outlook.
It crashes here:
$EwsService.FindItems( $RecipientCacheFolder.Id, $ItemView)
With the error:
Exception calling "FindItems" with "2" argument(s): "An internal server error occurred. The operation failed., [FindItem::Execute] itemShape is null. Parameter name: itemShape"
I find zero reference to that error on Internet.
Any ideas?
Thanks