protected override void InternalProcessRecord() { TaskLogger.LogEnter(); try { base.InternalProcessRecord(); if (!base.HasErrors) { ADUser user = this.DataObject as ADUser; ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(base.SessionSettings, user); using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Enable-ServiceEmailChannel")) { using (Folder folder = Folder.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Root), StoreObjectType.Folder, "Service E-Mail", CreateMode.CreateNew)) { folder.ClassName = "IPF.Note"; folder.Save(); folder.Load(); mailboxSession.SetReceiveFolder("IPM.Note.Custom.ServiceEmail", folder.StoreObjectId); } } } } catch (StorageTransientException ex) { TaskLogger.LogError(ex); base.WriteError(ex, ErrorCategory.ReadError, this.DataObject); } catch (StoragePermanentException ex2) { TaskLogger.LogError(ex2); base.WriteError(ex2, ErrorCategory.InvalidOperation, this.DataObject); } finally { TaskLogger.LogExit(); } }