RemoveDelegateType Class

The RemoveDelegateType class represents a request to remove delegates from a mailbox.

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

Syntax

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

Inheritance Hierarchy

System.Object
   ExchangeWebServices.BaseRequestType
     ExchangeWebServices.BaseDelegateType
      ExchangeWebServices.RemoveDelegateType

Example

The following example shows you how to remove two delegates from user1's mailbox. In this example, one delegate is removed by using the delegate's primary Simple Mail Transfer Protocol (SMTP) address and the other is removed by using the delegate's security identifier (SID).

static void RemoveDelegate()
{
    // Set the version, credentials, and the Client Access server on ExchangeServiceBinding.
    ExchangeServiceBinding esb = new ExchangeServiceBinding();
    esb.RequestServerVersionValue = new RequestServerVersion();
    esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
    esb.Credentials = new NetworkCredential("username", "password", "domain");
    esb.Url = "https://FQDN/ews/exchange.asmx";

    // Identify the delegates to be removed.
    UserIdType delegateUser1 = new UserIdType();
    UserIdType delegateUser2 = new UserIdType();
    delegateUser1.PrimarySmtpAddress = "user2@example.com";
    delegateUser2.SID = "S-1-5-21-1333220396-2200287332-232816053-1123";
    UserIdType[] delegateUsers = new UserIdType[2] { delegateUser1, delegateUser2 };

    // Form the RemoveDelegate request.
    RemoveDelegateType request = new RemoveDelegateType();
    request.Mailbox = new EmailAddressType();
    request.Mailbox.EmailAddress = "user1@example.com";
    request.UserIds = delegateUsers;

    try
    {
        // Send the RemoveDelegate request and get the response.
        RemoveDelegateResponseMessageType response = esb.RemoveDelegate(request);
        DelegateUserResponseMessageType[] durmt = new DelegateUserResponseMessageType[] { };
        durmt = response.ResponseMessages;

        // Check each response message.
        foreach (DelegateUserResponseMessageType resp in durmt)
        {
            if (resp.ResponseClass == ResponseClassType.Success)
            {
                Console.WriteLine("Delegate user was removed.");
            }
            else if (resp.ResponseClass == ResponseClassType.Error)
            {
                Console.WriteLine("Delegate user was not removed, due to error: " + resp.MessageText);
            }
            else
            {
                Console.WriteLine("Warning: " + resp.MessageText);
            }
        }
        Console.ReadLine();
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}

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)