WinRb / Viewpoint

A Ruby client access library for Microsoft Exchange Web Services (EWS)
Apache License 2.0
248 stars 171 forks source link

Unable to Move Messages #201

Open ghost opened 9 years ago

ghost commented 9 years ago

Hello, I've been having some issues with moving or copying messages to folders. I get the following error.

Viewpoint::EWS::Errors::SoapResponseError: SOAP Error: Message: The request failed schema validation: The element 'MoveItem' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'ReturnNewItemIds' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'. Code: a:ErrorSchemaValidation

This is how I'm currently trying to move the message...


cli = Viewpoint::EWSClient.new(endpoint, username, password) inbox = cli.get_folder :inbox new_folder = cli.get_folder_by_name 'Processed'

first_message = inbox.messages(indexed_page_item_view: {'MaxEntriesReturned' => 1, 'Offset' => 1, 'BasePoint' => 'Beginning'}).first

first_message.move!(new_folder.id)


I have also tried first_message.move(new_folder) both do not work.

This is where the error is triggered. Is there something I'm missing?

ghost commented 9 years ago

I found that by commenting out the line in the ews_data_services.rb for both the copy_item and move_item methods it would then work. This was the line I commented out. builder.return_new_item_ids!(return_new_ids)

zeha commented 8 years ago

See http://stackoverflow.com/a/19574710/2298386 - you need to have server version 2010 or newer and set :server_version when initialising your EWSClient instance.

ssendev commented 6 years ago

here is a monkey patch for @jakesandwich's solution. it would also be possible to leave the function body empty but i ditn't know if it breaks or fixes other things so i left it like jake

module FixOldEwsBuilder
  def return_new_item_ids!(opts)
    super unless ['move_item', 'copy_item'].include? caller_locations(1,1).first.base_label
  end
end
Viewpoint::EWS::SOAP::EwsBuilder.prepend FixOldEwsBuilder

this is a duplicate of #130