Edit

Share via


DeleteFolderType Class

Definition

The DeleteFolderType class represents a request to delete folders from a mailbox.

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

Examples

The following code example shows the soft-deletion of two folders.

static void DeleteFolder(ExchangeServiceBinding esb)
{ 
    // Identify the folders to delete.
    FolderIdType folder1 = new FolderIdType();
    FolderIdType folder2 = new FolderIdType();
    folder1.Id = "AQAlAE1B1";
    folder2.Id = "AQAlAE1B2";
    FolderIdType[] folders = new FolderIdType[2] { folder1, folder2 };

    // Form the delete folder request.
    DeleteFolderType <span class="label">request</span> = new DeleteFolderType();
<span class="label">request</span>.FolderIds = folders;
<span class="label">request</span>.DeleteType = DisposalType.SoftDelete;

    try
    {
        // Send the request and get the response.
        DeleteFolderResponseType response = esb.DeleteFolder(<span class="label">request</span>);
        ArrayOfResponseMessagesType aormt = response.ResponseMessages;
        ResponseMessageType[] rmta = aormt.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            if (rmt.ResponseClass == ResponseClassType.Error)
            {
                Console.WriteLine("Folder was not deleted.");
            }
            else if (rmt.ResponseClass == ResponseClassType.Success)
            {
                Console.WriteLine("Folder was deleted.");
            }
            else
                Console.WriteLine("Warning");
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

Remarks

Use the DeleteFolderType type to delete unmanaged folders and managed folders. You cannot delete default folders, such as the Inbox or Deleted Items folders, by using this operation.

Constructors

DeleteFolderType()

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

Properties

DeleteType

The DeleteType property gets or sets an enumeration that describes how folders are deleted. This property is required. This is a read/write property.

FolderIds

The FolderIds property gets or sets a set of folder identifiers for folders to delete from a mailbox. This property gets or sets a set of FolderIdType objects. This property is required. This is a read/write property.

Applies to