Export (0) Print
Expand All

GetDelegateType class

The GetDelegateType class represents a request to get delegate settings for a mailbox in the Exchange database.

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

'Declaration
<SerializableAttribute> _
PublicClassGetDelegateType _
	InheritsBaseDelegateType
'Usage
DiminstanceAsGetDelegateType

The following example shows you how to retrieve the delegate settings for all the delegates that are set on user1's mailbox. All the permissions for each user are returned in the response.

static void GetDelegate()
{
    // 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";

    // Create the request.
    GetDelegateType request = new GetDelegateType();

    // Identify the mailbox for which to retrieve delegate settings.
    request.Mailbox = new EmailAddressType();
    request.Mailbox.EmailAddress = "user1@example.com";
    request.IncludePermissions = true;

    try
    {
        // Send the GetDelegate request and get the response.
        GetDelegateResponseMessageType response = esb.GetDelegate(request);
        DelegateUserResponseMessageType[] durmt = new DelegateUserResponseMessageType[] { };
        if (response.ResponseMessages != null)
        {
            durmt = response.ResponseMessages;
        }
        else
        {
            Console.WriteLine("There are no delegates for " + request.Mailbox.EmailAddress);
        }

        // Check each response message.
        foreach (DelegateUserResponseMessageType resp in durmt)
        {
            if (resp.ResponseClass == ResponseClassType.Success)
            {
                DelegateUserType dut = resp.DelegateUser;
                Console.WriteLine("=====================");
                Console.WriteLine("Delegate user's display name: " + dut.UserId.DisplayName);
                Console.WriteLine("Primary SMTP address: " + dut.UserId.PrimarySmtpAddress);
                Console.WriteLine("Calendar folder permission level: " + dut.DelegatePermissions.CalendarFolderPermissionLevel.ToString());
                Console.WriteLine("Contacts folder permission level: " + dut.DelegatePermissions.ContactsFolderPermissionLevel.ToString());
                Console.WriteLine("Journal folder permission level: " + dut.DelegatePermissions.JournalFolderPermissionLevel.ToString());
                Console.WriteLine("Delegate user receives copies of meeting messages? " + dut.ReceiveCopiesOfMeetingMessages.ToString());
                Console.WriteLine("Delegate user can view private items? " + dut.ViewPrivateItems);
            }
            else if (resp.ResponseClass == ResponseClassType.Error)
            {
                Console.WriteLine("Error: " + resp.MessageText);
            }
            else
                Console.WriteLine("Warning: " + resp.MessageText);
        }

        //Identify who receives meeting requests.
        Console.WriteLine("=====================");
        Console.WriteLine("Meeting requests are delivered to: " + response.DeliverMeetingRequests.ToString());
        Console.ReadLine();
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft