This topic has not yet been rated - Rate this topic

UpdateFolderType class

The Exchange Web Services (EWS) autogenerated proxy object models that are created by .NET Framework proxy generators are deemphasized and we do not recommend that you use them for new .NET Framework client development. We recommend that you use the EWS Managed API to develop clients that target the .NET Framework. We recommend that you use the EWS Java API to develop clients that target the Java platform. For more information about the EWS Managed API, see Explore the EWS Managed API.

The UpdateFolderType class represents a request to update folders in a mailbox.

System.Object
  ExchangeWebServices.BaseRequestType
    ExchangeWebServices.UpdateFolderType

Namespace:  ExchangeWebServices
Assembly:  EWS (in EWS.dll)
[SerializableAttribute]
public class UpdateFolderType : BaseRequestType

You can append, set, or delete properties when you are updating a folder.

The following table lists the error response codes that can be returned for an UpdateFolder operation.

UpdateFolder operation error response codes

ResponseCode

Description

ErrorInvalidPropertySet

An attempt was made to set a value for a property that is read-only.

ErrorChangeKeyRequiredForWriteOperations

A change key was not provided for the update operation.

ErrorIncorrectUpdatePropertyCount

An attempt was made to submit a change description that includes more than one property to modify.

The following code example shows you how to update the display name of a folder. The folder identifier and change key have been shortened to preserve readability.

static void UpdateFolder(ExchangeServiceBinding esb)
{
    // Create the container for the set of updates to be made to the folders.
    FolderChangeType changes = new FolderChangeType();

    // Identify the folder to change.
    FolderIdType folderId = new FolderIdType();
    folderId.Id = "AQAlAE1BQG1h=";
    folderId.ChangeKey = "AQAAABYA";
    changes.Item = folderId;

    // Create the update. Identify the field to update and the value to set for it.
    SetFolderFieldType uDisplayName = new SetFolderFieldType();
    PathToUnindexedFieldType displayNameProp = new PathToUnindexedFieldType();
    displayNameProp.FieldURI = UnindexedFieldURIType.folderDisplayName;
    FolderType updatedFolder = new FolderType();
    updatedFolder.DisplayName = "My new folder name";
    uDisplayName.Item = displayNameProp; 
    uDisplayName.Item1 = updatedFolder;
    
    // Add the folder to change.
    changes.Item = folderId;

    // Add the array of changes; in this case, a single element array.
    changes.Updates = new FolderChangeDescriptionType[1] { uDisplayName };

    // Add changes to the request.
    UpdateFolderType request = new UpdateFolderType();
    request.FolderChanges = new FolderChangeType[1] { changes };

    // Send the request and get the response.
    UpdateFolderResponseType response = esb.UpdateFolder(request);
    ArrayOfResponseMessagesType aormt = response.ResponseMessages;
    ResponseMessageType[] rmta = aormt.Items;

    // Get the new change key for the updated folder.
    foreach (ResponseMessageType rmt in rmta)
    {
        FolderInfoResponseMessageType firmt = (rmt as FolderInfoResponseMessageType);

        foreach (BaseFolderType folder in firmt.Folders)
        {
            Console.WriteLine("New change key: " + folder.FolderId.ChangeKey);
        }
    }
}
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.