How to prevent notification when deleting an appointment EWS?

I'm using the following code to delete items in the "deleted items folder" which all works well. However, when the item is an appointment the members all receive an cancelation notification. How can I prevent sending a notification to all members?

Thnx Remco

	$FolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
	$ItemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)
	$wkfn = [Microsoft.Exchange.WebServices.Data.WellKnownFolderName]
	$TargetFolder = New-Object Microsoft.Exchange.WebServices.Data.FolderId($wkfn::DeletedItems,$AccountMailbox)
	$DeletedItems = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($ExchangeService,$TargetFolder) 
	$dateTimeItem = [Microsoft.Exchange.WebServices.Data.ItemSchema]::DateTimeReceived             
	#$15MinutesAgo = (Get-Date).AddMinutes(-15)
	$15MinutesAgo = (Get-Date).AddDays(-360)
	$SearchFilter = New-Object -TypeName Microsoft.Exchange.WebServices.Data.SearchFilter+IsLessThanOrEqualTo  -ArgumentList $dateTimeItem,$15MinutesAgo
	$findItemResults = $DeletedItems.FindItems($ItemView)
	$foundItems = $exchangeService.FindItems($DeletedItems.Id,$searchFilter,$itemView)
	$Deleted = 0
	
	do{
	$foundItems = $exchangeService.FindItems($DeletedItems.Id,$searchFilter,$itemView)
	
	foreach ($item in $foundItems) {
		#$item.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
		$Deleted++
	}

	}while($foundItems.MoreAvailable -eq $true)

May 4th, 2015 5:41am

fixed it with this code:

$item.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete,[Microsoft.Exchange.WebServices.Data.SendCancellationsMode]::SendToNone)

  • Marked as answer by Remco Tiel 18 hours 35 minutes ago
Free Windows Admin Tool Kit Click here and download it now
May 4th, 2015 8:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics