static DelegateUserResponse updateDelegates(string del) { LogLine("Updating delegate permissions for user '" + del + "'"); Mailbox mailbox = new Mailbox(del); DelegateInformation result = service.GetDelegates(mailbox, true); Collection <DelegateUserResponse> resps = result.DelegateUserResponses; LogLine("Found " + resps.Count + " delegates for user '" + del + "'"); foreach (DelegateUserResponse r in resps) { LogLine(r.Result.ToString()); } // Create a list to hold the updated delegates. List <DelegateUser> updatedDelegates = new System.Collections.Generic.List <DelegateUser>(); // Set the new permissions for the delegate. DelegateUser taskDelegate = new DelegateUser(discoverUser); taskDelegate.Permissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevel.Author; taskDelegate.Permissions.TasksFolderPermissionLevel = DelegateFolderPermissionLevel.Author; updatedDelegates.Add(taskDelegate); Collection <DelegateUserResponse> response = service.UpdateDelegates(mailbox, MeetingRequestsDeliveryScope.DelegatesAndSendInformationToMe, updatedDelegates); DelegateUserResponse resp = null; foreach (DelegateUserResponse r in response) { resp = r; break; } return(resp); }
public static ICollection <DelegateUser> GetDelegates(ExchangeService service, Mailbox primaryAccount) { DelegateInformation response = service.GetDelegates(primaryAccount, true); List <DelegateUser> delegateUsers = null; if (response.DelegateUserResponses.Count > 0) { delegateUsers = new List <DelegateUser>(); foreach (DelegateUserResponse delegateResponse in response.DelegateUserResponses) { delegateUsers.Add(delegateResponse.DelegateUser); } } return(delegateUsers); }
public DelegateInformation GetDelegates() { DelegateInformation result = service.GetDelegates(mailbox, true); foreach (DelegateUserResponse response in result.DelegateUserResponses) { if (response.Result != ServiceResult.Success) { //ErrorDelegateNoUser means the delegate is a group, which the EWS API can't handle, //so we ignore it. if (response.ErrorCode.ToString() != "ErrorDelegateNoUser") { throw new EWSException(response.ErrorCode.ToString(), response); } } } return(result); }