none
Create a clone of item using EWS Managed API RRS feed

  • Question

  • Please suggest how to create a clone of Email Mesage using EWS Managed API.

    For example, I want to move the mail to another folder and then also forward it. but after i move it to another folder, I can't forward it. The error shows: "The objecty is not found in the store".

    In outlook it's not a problem.

    Wednesday, February 16, 2011 12:16 PM

All replies

  • When you move an Item it will be assigned a new EWSId so if your trying to use the sourceItem it will no longer work as this will refer to the old EWSId which is what the error seems to be pointing to. To cater for this you shoud grab the SourceKey before the move and then find the new EWSId of the moved Item use a findItems query eg

    ItemView iv = new ItemView(1);
    ExtendedPropertyDefinition PR_Search_Key = new ExtendedPropertyDefinition(12299, MapiPropertyType.Binary);
    PropertySet psProperSet = new PropertySet();
    psProperSet.Add(PR_Search_Key);
    iv.PropertySet = psProperSet;
    FindItemsResults<Item> fiItems = service.FindItems(WellKnownFolderName.Inbox, iv);
    Item SourceItem = fiItems.Items[0];
    SourceItem.Move(WellKnownFolderName.JunkEmail);
    SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(PR_Search_Key,Convert.ToBase64String((byte[])SourceItem.ExtendedProperties[0].Value));
    FindItemsResults<Item> mvMoveItems = service.FindItems(WellKnownFolderName.JunkEmail,sfSearchFilter, iv);
    Item MovedItem = mvMoveItems.Items[0];
    
    Cheers
    Glen
    Thursday, February 17, 2011 1:47 AM