Sdílet prostřednictvím


DeleteItemType Class

The DeleteItemType class represents a request to delete items in an Exchange database.

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 DeleteItemType
    Inherits BaseRequestType
[SerializableAttribute] 
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[DesignerCategoryAttribute("code")] 
[XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages")] 
[DebuggerStepThroughAttribute] 
public class DeleteItemType : 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 DeleteItemType : 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 DeleteItemType extends BaseRequestType
SerializableAttribute 
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
DesignerCategoryAttribute("code") 
XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") 
DebuggerStepThroughAttribute 
public class DeleteItemType extends BaseRequestType

Remarks

The DeleteItemType class is used to delete items from a user's mailbox. The RemoveItem response object on a meeting cancellation notice should be used to remove canceled meetings from a user's mailbox.

The order of the items that is specified by the ItemIds property determines the order of the response messages that are returned in the response. This means that the second item that is identified to be deleted will correspond to the second response message. One response message is created for each item that is to be deleted.

Inheritance Hierarchy

System.Object
   ExchangeWebServices.BaseRequestType
    ExchangeWebServices.DeleteItemType

Example

The following code example shows you how to delete two items. The deleted items are moved to the Deleted Items folder. If the item is a task, only the specified task is deleted. If the item is a meeting, a meeting cancellation is sent to all the attendees.

static void DeleteItem(ExchangeServiceBinding esb)
{ 
    // Create the request.
    DeleteItemType request = new DeleteItemType();

    // Identify the items to delete.
    ItemIdType[] items = new ItemIdType[2];
    items[0] = new ItemIdType();
    items[0].Id = "AAAlAE1BQG1";
    items[1] = new ItemIdType();
    items[1].Id = "AAAlAE1BQG2";
    request.ItemIds = items;

    // Identify how deleted items are handled.
    request.DeleteType = DisposalType.MoveToDeletedItems;

    // Identify how tasks are deleted.
    request.AffectedTaskOccurrences = AffectedTaskOccurrencesType.SpecifiedOccurrenceOnly;
    request.AffectedTaskOccurrencesSpecified = true;

    // Identify how meeting cancellations are handled.
    request.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendOnlyToAll;
    request.SendMeetingCancellationsSpecified = true;

    try
    {
        // Send the response and receive the request.
        DeleteItemResponseType response = esb.DeleteItem(request);
        ArrayOfResponseMessagesType aormt = response.ResponseMessages;
        ResponseMessageType[] rmta = aormt.Items;

        // Check each response message.
        foreach (ResponseMessageType rmt in rmta)
        {
            if (rmt.ResponseClass == ResponseClassType.Success)
            {
                Console.WriteLine("Deleted item.");
            }
        }
    }
    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)