Поделиться через


DeleteFolderType Class

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

Inheritance Hierarchy

System.Object
  ExchangeWebServices.BaseRequestType
    ExchangeWebServices.DeleteFolderType

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

Syntax

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

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.

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 request = new DeleteFolderType();
    request.FolderIds = folders;
    request.DeleteType = DisposalType.SoftDelete;

    try
    {
        // Send the request and get the response.
        DeleteFolderResponseType response = esb.DeleteFolder(request);
        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);
    }
}

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.