Edit

Share via


GetDelegateType Class

Definition

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

public ref class GetDelegateType : ExchangeWebServices::BaseDelegateType
public class GetDelegateType : ExchangeWebServices.BaseDelegateType
Public Class GetDelegateType
Inherits BaseDelegateType
Inheritance

Examples

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();
    }
}

Constructors

GetDelegateType()

The GetDelegateType constructor initializes a new instance of the GetDelegateType class.

Properties

IncludePermissions

The IncludePermissions property gets or sets a Boolean value that specifies whether permission settings for delegates are included in the response.

Mailbox

The Mailbox property gets or sets an EmailAddressType object that represents a mail-enabled Active Directory directory service object.

(Inherited from BaseDelegateType)
UserIds

The UserIds property gets or sets a UserIdType array that represents the delegates to get from a mailbox.

Applies to