Compartir a través de


UpdateFolderType Class

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

Inheritance Hierarchy

System.Object
  ExchangeWebServices.BaseRequestType
    ExchangeWebServices.UpdateFolderType

Namespace:  ExchangeWebServices
Assembly:  EWS (in EWS.dll)

Syntax

'Declaration
<SerializableAttribute> _
Public Class UpdateFolderType _
    Inherits BaseRequestType
'Usage
Dim instance As UpdateFolderType
[SerializableAttribute]
public class UpdateFolderType : BaseRequestType

Remarks

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.

Examples

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.