Error when moving mails between folders

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
  }
}

July 9th, 2013 4:23am

I would suggest you enable Tracing and have a look/post the response you get from the server when the error occurs http://msdn.microsoft.com/en-us/library/exchange/dd633676(v=exchg.80).aspx.

How many items are you moving ? if its a large number you maybe getting throttled.

The other question is why have you got Items in the Outbox in the normal course of events normal Items shouldn't be saved in this folder unless there is another problem.

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2013 2:59am

Hi Glen,

thanks. A tracing is a good idea.
I am moving from 1-200 items/mailbox. A sample mailbox has 3 items in outbox.

About having items in outbox - some users still use Outlook 2007 and do not have necessary patch installed.

Thanks.

July 10th, 2013 3:42am

Hi Glen,

this is a traced request/response:

 

<Trace Tag="EwsRequest" Tid="6" Time="2013-07-10 09:42:32Z" Version="15.00.0516.014">
  <?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
      <t:RequestServerVersion Version="Exchange2010_SP2" />
      <t:ExchangeImpersonation>
        <t:ConnectingSID>
          <t:SmtpAddress>targetuser@domain.com</t:SmtpAddress>
        </t:ConnectingSID>
      </t:ExchangeImpersonation>
    </soap:Header>
    <soap:Body>
      <m:MoveItem>
        <m:ToFolderId>
          <t:DistinguishedFolderId Id="sentitems" />
        </m:ToFolderId>
        <m:ItemIds>
          <t:ItemId Id="AAMkADExMDI0MjcyLTgwOWUtNGQwNi1iNTc1LTM2ZGJmZGMyN2ZiOABGAAAAAAAEh0ZJvJC7Ra+ojsq+4gj4BwBZGmfnJSRxQ6+lLXPx5mjGAAAAGWoWAAAnEcSixPLTQ4athfzPTwLnAAANUY9RAAA=" ChangeKey="DAAAABYAAAAnEcSixPLTQ4athfzPTwLnAAANUzMZ" />
        </m:ItemIds>
      </m:MoveItem>
    </soap:Body>
  </soap:Envelope>
</Trace>

<Trace Tag="EwsResponseHttpHeaders" Tid="6" Time="2013-07-10 09:42:32Z">
  <?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
      <h:ServerVersionInfo MajorVersion="14" MinorVersion="2" MajorBuildNumber="342" MinorBuildNumber="4" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <m:MoveItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
        <m:ResponseMessages>
          <m:MoveItemResponseMessage ResponseClass="Error">
            <m:MessageText>The move or copy operation failed.</m:MessageText>
            <m:ResponseCode>ErrorMoveCopyFailed</m:ResponseCode>
            <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
            <m:Items />
          </m:MoveItemResponseMessage>
        </m:ResponseMessages>
      </m:MoveItemResponse>
    </s:Body>
  </s:Envelope>
</Trace>

I still have no idea why it fails :(

Free Windows Admin Tool Kit Click here and download it now
July 10th, 2013 5:52am

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

Other recent topics Other recent topics