DeleteFolderType Class

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

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

Syntax

'Declaration
<SerializableAttribute> _
<GeneratedCodeAttribute("wsdl", "2.0.50727.42")> _
<DesignerCategoryAttribute("code")> _
<XmlTypeAttribute(Namespace:="https://schemas.microsoft.com/exchange/services/2006/messages")> _
<DebuggerStepThroughAttribute> _
Public Class DeleteFolderType
    Inherits BaseRequestType
[SerializableAttribute] 
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[DesignerCategoryAttribute("code")] 
[XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages")] 
[DebuggerStepThroughAttribute] 
public class DeleteFolderType : BaseRequestType
[SerializableAttribute] 
[GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")] 
[DesignerCategoryAttribute(L"code")] 
[XmlTypeAttribute(Namespace=L"https://schemas.microsoft.com/exchange/services/2006/messages")] 
[DebuggerStepThroughAttribute] 
public ref class DeleteFolderType : public BaseRequestType
/** @attribute SerializableAttribute() */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute DesignerCategoryAttribute("code") */ 
/** @attribute XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") */ 
/** @attribute DebuggerStepThroughAttribute() */ 
public class DeleteFolderType extends BaseRequestType
SerializableAttribute 
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
DesignerCategoryAttribute("code") 
XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") 
DebuggerStepThroughAttribute 
public class DeleteFolderType extends 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.

Inheritance Hierarchy

System.Object
   ExchangeWebServices.BaseRequestType
    ExchangeWebServices.DeleteFolderType

Example

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.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003,

Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Longhorn, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional with Service Pack 2 (SP2)