/// <summary> /// Saves public folder information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnPFSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hfPublicFolderPath.Value)) notification1.SetMessage(controls.notification.MessageType.Warning, "You must first select a public folder before trying to save properties."); else { ExchCmds powershell = null; try { // Initialize the powershell module powershell = new ExchCmds(Config.ExchangeURI, Config.Username, Config.Password, Config.ExchangeConnectionType, Config.PrimaryDC); // Set the public folder int warningSize, prohibitSize, maxItemSize, ageLimit, keepDeletedItems = 0; // Parse the values int.TryParse(txtWarningSizeMB.Text, out warningSize); int.TryParse(txtProhibitPostMB.Text, out prohibitSize); int.TryParse(txtMaxItemSize.Text, out maxItemSize); int.TryParse(txtAgeLimit.Text, out ageLimit); int.TryParse(txtKeepDeletedItems.Text, out keepDeletedItems); powershell.Set_PublicFolder(hfPublicFolderPath.Value, warningSize, prohibitSize, maxItemSize, ageLimit, keepDeletedItems, Config.ExchangeVersion); // Show saved message notification1.SetMessage(controls.notification.MessageType.Warning, "Successfully saved public folder information but was unable to modify the email settings."); // Now continue to the mail section if (!cbPFCurrentEmailEnabled.Checked && cbPFEnableEmail.Checked) { // User is enabling email on the public folder if (string.IsNullOrEmpty(txtDisplayName.Text) || string.IsNullOrEmpty(txtPrimaryEmail.Text)) throw new Exception("You must fill out the display name and email address if you want to mail enable a public folder."); powershell.Enable_MailPublicFolder(hfPublicFolderPath.Value, cbPFHiddenFromAddressLists.Checked, CPContext.SelectedCompanyCode, txtDisplayName.Text, string.Format("{0}@{1}", txtPrimaryEmail.Text.Replace(" ", string.Empty), ddlEmailDomains.SelectedValue)); } else if (cbPFCurrentEmailEnabled.Checked && !cbPFEnableEmail.Checked) { // User is disabling email on the public folder powershell.Disable_MailPublicFolder(hfPublicFolderPath.Value); } else if (cbPFCurrentEmailEnabled.Checked && cbPFEnableEmail.Checked) { // User is just modifing settings on the mail public folder if (string.IsNullOrEmpty(txtDisplayName.Text) || string.IsNullOrEmpty(txtPrimaryEmail.Text)) throw new Exception("You must fill out the display name and email address if you want to change a mail enabled public folder."); powershell.Set_MailPublicFolder(hfPublicFolderPath.Value, cbPFHiddenFromAddressLists.Checked, CPContext.SelectedCompanyCode, txtDisplayName.Text, string.Format("{0}@{1}", txtPrimaryEmail.Text.Replace(" ", string.Empty), ddlEmailDomains.SelectedValue)); } // Show success message notification1.SetMessage(controls.notification.MessageType.Success, "Successfully updated all public folder information."); } catch (Exception ex) { notification1.SetMessage(controls.notification.MessageType.Error, "Error saving public folder information: " + ex.Message); } finally { if (powershell != null) powershell.Dispose(); // Refresh the current public folder GetPublicFolder(hfPublicFolderPath.Value); } } }