Edit

Share via


UpdateFolderType Class

Definition

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

public ref class UpdateFolderType : ExchangeWebServices::BaseRequestType
public class UpdateFolderType : ExchangeWebServices.BaseRequestType
Public Class UpdateFolderType
Inherits BaseRequestType
Inheritance
UpdateFolderType

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 <span class="label">request</span> = new <span class="label">UpdateFolderType</span>();
<span class="label">request</span>.FolderChanges = new FolderChangeType[1] { changes };

    // Send the request and get the response.
    UpdateFolderResponseType response = esb.UpdateFolder(<span class="label">request</span>);
    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);
        }
    }
}

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

ErrorInvalidPropertySetAn attempt was made to set a value for a property that is read-only.
ErrorChangeKeyRequiredForWriteOperationsA change key was not provided for the update operation.
ErrorIncorrectUpdatePropertyCountAn attempt was made to submit a change description that includes more than one property to modify.

Constructors

UpdateFolderType()

The UpdateFolderType constructor initializes a new instance of the UpdateFolderType class.

Properties

FolderChanges

The FolderChanges property gets or sets an array of changes that are made to a set of folders. This property is required. This is a read/write property.

Applies to