protected override void ProcessRecord() { DelegateFolderPermissionLevel[] folderPermission = { this.CalendarPermission, this.InboxPermission, this.TaskPermission, this.ContactPermission }; XEwsDelegate delegateUser = new XEwsDelegate(this.DelegateEmailAddress, this.ReceiveCopyOfMeetings, this.ViewPrivateItems, folderPermission); this.SetDelegate(delegateUser, DelegateAction.Add); }
/// <summary> /// Method is used for setting, updating and deleting delegate. /// </summary> /// <param name="xewsDelegate">Delegate object for manipulation.</param> /// <param name="delegateAction">Action on delegate (Add, Update, Delete).</param> internal void SetDelegate(XEwsDelegate xewsDelegate, DelegateAction delegateAction) { ExchangeService ewsSession = this.GetSessionVariable(); this.ValidateEmailAddress(xewsDelegate.DelegateUserId); string currentBindedMailbox = this.GetBindedMailbox(); DelegateUser delegateUser = new DelegateUser(xewsDelegate.DelegateUserId); Mailbox currentMailbox = new Mailbox(currentBindedMailbox); delegateUser.ReceiveCopiesOfMeetingMessages = xewsDelegate.ReceivesCopyOfMeeting; delegateUser.Permissions.CalendarFolderPermissionLevel = xewsDelegate.CalendarFolderPermission; delegateUser.Permissions.InboxFolderPermissionLevel = xewsDelegate.InboxFolderPermission; delegateUser.Permissions.ContactsFolderPermissionLevel = xewsDelegate.ContactFolderPermission; delegateUser.Permissions.TasksFolderPermissionLevel = xewsDelegate.TaskFolderPermission; switch (delegateAction) { case DelegateAction.Update: ewsSession.UpdateDelegates(currentMailbox, MeetingRequestsDeliveryScope.DelegatesAndMe, delegateUser); break; case DelegateAction.Add: ewsSession.AddDelegates(currentMailbox, MeetingRequestsDeliveryScope.DelegatesAndMe, delegateUser); break; case DelegateAction.Delete: ewsSession.RemoveDelegates(currentMailbox, delegateUser.UserId); break; } }
protected override void ProcessRecord() { XEwsDelegate xewsDelegate = new XEwsDelegate(this.DelegateEmailAddress); this.SetDelegate(xewsDelegate, DelegateAction.Delete); }