none
How to prevent notification when deleting an appointment EWS? RRS feed

  • Question

  • 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)

    Monday, May 4, 2015 9:39 AM

Answers

  • 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 Monday, May 4, 2015 12:49 PM
    Monday, May 4, 2015 12:49 PM