Exchange 2007 - Web Services - MoveItem No Longer Returns ID

Answered Exchange 2007 - Web Services - MoveItem No Longer Returns ID

All Replies

  • Tuesday, January 23, 2007 3:39 PM
     
     

    Actually I am struggling a little here. If anyone has an example of how to append an extended field to an existing email sitting in the inbox then that would be great.

    Thanks,
    John

  • Tuesday, January 23, 2007 6:00 PM
     
     

    The reason that we removed the Ids from both MoveItem and CopyItem responses was that obtaining the Ids required an explicit search in the destination directory for each moved item.  When moving or copying a lot of item, perf went down considerably.  Certainly, there are situations where you need the new ids for the items, but there are also items when you do not.  As such, we decided to remove the "tax" from the equation and if consumers want to get the new ids, they can find them themselves.

     

    To do this, you essentially do what we had in the code during beta.  Before moving the item, grab the PR_SEARCHKEY via GetItem and then after the move, do a FindItem and restrict on that search key.

  • Tuesday, January 23, 2007 6:26 PM
     
     Answered

    Just grab the Id of the message in the inbox and then call this method...  You will also need to create your own extended prop (Example below)

     

    public static ItemIdType AppendExtendedProp(

                      ExchangeServiceBinding binding,

                      ExtendedPropertyType extendedProperty,

                      ItemIdType id)

    {

    UpdateItemType request = new UpdateItemType();

    request.ConflictResolution = ConflictResolutionType.AlwaysOverwrite;

    request.MessageDisposition = MessageDispositionType.SaveOnly;

    request.MessageDispositionSpecified = true;

    ItemType updatedItem = new ItemType();

    updatedItem.ExtendedProperty = new ExtendedPropertyType[]{extendedProperty};

    SetItemFieldType setItem = new SetItemFieldType();

    setItem.Item = extendedProperty.ExtendedFieldURI;

    setItem.Item1 = updatedItem;

    ItemChangeType itemChange = new ItemChangeType();

    itemChange.Item = id;

    itemChange.Updates = new ItemChangeDescriptionType[] { setItem };

    request.ItemChanges = new ItemChangeType[] { itemChange };

    UpdateItemResponseType response = binding.UpdateItem(request);

    ItemInfoResponseMessageType responseMessage = response.ResponseMessages.Items[0] as ItemInfoResponseMessageType;

    if (responseMessage.ResponseCode != ResponseCodeType.NoError)

    {

    //Explode();

    }

    return responseMessage.Items.Items[0].ItemId;

    }

     

     

    And here is an example of calling it...

    ExtendedPropertyType ep = new ExtendedPropertyType();

    PathToExtendedFieldType epPath = new PathToExtendedFieldType();

    epPath.PropertySetId = Guid.NewGuid().ToString("D"); // just create a namespace for our custom prop

    epPath.PropertyName = "Fuzzy Blue Property";  // creative property name

    epPath.PropertyType = MapiPropertyTypeType.String;

    ep.ExtendedFieldURI = epPath;

    ep.Item = "Blue123";  // property value

    // Note that Id is the Id of the item in the inbox

    AppendExtendedProp(binding, ep, id);

  • Wednesday, January 24, 2007 2:08 PM
     
     

    Thanks David, I've now got the app running back as it was under Beta2, with the added benefit of the delay no longer being an issue.

    May sound like a strange request, but if the reason that you removed the return of IDs was due to performance issues when working with large numbers of items, it would be nice to have 2 methods for each operation - MoveItem and MoveItemReturningID perhaps. This might make EWS much larger, but would significantly reduce the complexity of my code. I'm dreading the day I need to come back and bugfix my app!

    Many thanks again for your responsiveness,
    John

  • Wednesday, January 24, 2007 4:25 PM
     
     
    That isn't a strange request.  I entered it for consideration (this has come up before).  Rather than having a separate method, it would make more sense to add an attribute to the method called ReturnIds (bool) that will return the Ids if true.  As it stands, both MoveItem and CopyItem return ItemInfoResponseMessageType instances, so no changes would be necessary there.  We will see what the powers that be say about it.