Adding delegates in Exchange Web Services (Exchange Server 2007 SP1)

                    Le Café Central de Deva              

                                 ..... Deva blogs!!



Adding delegates in Exchange Web Services (Exchange Server 2007 SP1)

  • Comments 1

Delegates & Exchange Web Services 

In Microsoft Exchange Server 2007 SP1, you can use Exchange Web Services to add, update, and remove delegates.

Code sample

Please find the code example that shows you how to add delegates that can take actions on behalf of a principal. In this code it shows how to add two delegate users to an account.

static void AddDelegate()
    // Set the version, credentials, and 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 = "";

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

    // Identify the principal's mailbox.
    request.Mailbox = new EmailAddressType();
    request.Mailbox.EmailAddress = "";

    // Identify the delegates who are given access to the principal's mailbox.
    request.DelegateUsers = new DelegateUserType[2];
    request.DelegateUsers[0] = new DelegateUserType();
    request.DelegateUsers[0].UserId = new UserIdType();
    request.DelegateUsers[0].UserId.PrimarySmtpAddress = "";
    request.DelegateUsers[1] = new DelegateUserType();
    request.DelegateUsers[1].UserId = new UserIdType();
    request.DelegateUsers[1].UserId.PrimarySmtpAddress = "";
    // Specify the permissions that are granted to each delegate.
    request.DelegateUsers[0].DelegatePermissions = new DelegatePermissionsType();
    request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevelType.Reviewer;
    request.DelegateUsers[0].DelegatePermissions.CalendarFolderPermissionLevelSpecified = true;
    request.DelegateUsers[1].DelegatePermissions = new DelegatePermissionsType();
    request.DelegateUsers[1].DelegatePermissions.TasksFolderPermissionLevel = DelegateFolderPermissionLevelType.Author;
    request.DelegateUsers[1].DelegatePermissions.TasksFolderPermissionLevelSpecified = true;
    request.DelegateUsers[1].DelegatePermissions.InboxFolderPermissionLevel = DelegateFolderPermissionLevelType.Editor;
    request.DelegateUsers[1].DelegatePermissions.InboxFolderPermissionLevelSpecified = true;

    // Specify whether the principal recieves meeting requests.
    request.DeliverMeetingRequests = DeliverMeetingRequestsType.DelegatesAndSendInformationToMe;
    request.DeliverMeetingRequestsSpecified = true;

        // Send the request and get the response.
        AddDelegateResponseMessageType response = esb.AddDelegate(request);
        DelegateUserResponseMessageType[] responseMessages = response.ResponseMessages;

        // One DelegateUserResponseMessageType exists for each attempt to add a delegate user to an account.
        foreach (DelegateUserResponseMessageType user in responseMessages)
            Console.WriteLine("Results of adding user: " + user.ResponseClass.ToString());
            if (user.DelegateUser.ReceiveCopiesOfMeetingMessagesSpecified)
                Console.WriteLine("Does the delegate receive copies of meeting related messages: " + user.DelegateUser.ReceiveCopiesOfMeetingMessages);
            if (user.DelegateUser.ViewPrivateItemsSpecified)
                Console.WriteLine("Can the delegate view private items in the principal's mailbox: " + user.DelegateUser.ViewPrivateItems);
    catch (Exception e)

For more information refer this article

  • Restore Exchange Server data with recovery storage groups Adding delegates in Exchange Web Services

Page 1 of 1 (1 items)
Blog - Post Feedback Form(CAPTCHA)
Leave a Comment
  • Post