Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Error when moving mails between folders

$
0
0

Hi,

I use PowerShell and WebServices DLL (I have tried different versions) to check and move messages inside a mailbox from Outbox to Sent Items. In 70% it works, but when processing some mailboxes I get an exception "The move or copy operation failed" on line  $item.Move("SentItems").

Not moved messages does not look corrupted - I can access them, move them in OWA. They are also not special (calendar event/response/deffered message).

Do you have any idea why?

Thanks
M.

A move message part:

($service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService)

 function Move-Messages {
  [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")]
  param(
    [Parameter(Position = 0, Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
 [string]
    $Id    
    )
  process { 
    $view = New-Object Microsoft.Exchange.WebServices.Data.ItemView -ArgumentList 1
    $propertyset = New-Object Microsoft.Exchange.WebServices.Data.PropertySet ([Microsoft.Exchange.WebServices.Data.BasePropertySet]::IdOnly)
    $view.PropertySet = $propertyset
    $item = [Microsoft.Exchange.WebServices.Data.Item]::Bind($service, $Id)
    $item.Move("SentItems")
    $view = $null
    $propertyset = $null
  }
}




Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>