private void EditSelectedExternalAccount() { if (listFetchAccounts.SelectedItems.Count < 1) { return; } int id = Convert.ToInt32(listFetchAccounts.SelectedItems[0].Tag); hMailServer.FetchAccounts fetchAccounts = _representedAccount.FetchAccounts; hMailServer.FetchAccount fetchAccount = fetchAccounts.get_ItemByDBID(id); formExternalAccount externalAccountDialog = new formExternalAccount(); externalAccountDialog.LoadAccountProperties(fetchAccount); if (externalAccountDialog.ShowDialog() == DialogResult.OK) { externalAccountDialog.SaveAccountProperties(fetchAccount); fetchAccount.Save(); } ListExternalAccounts(); Marshal.ReleaseComObject(fetchAccounts); Marshal.ReleaseComObject(fetchAccount); }
private void ListExternalAccounts() { listFetchAccounts.Items.Clear(); hMailServer.FetchAccounts fetchAccounts = _representedAccount.FetchAccounts; for (int i = 0; i < fetchAccounts.Count; i++) { hMailServer.FetchAccount fetchAccount = fetchAccounts.get_Item(i); string name = fetchAccount.Name; string enabled = EnumStrings.GetYesNoString(fetchAccount.Enabled); ListViewItem item = listFetchAccounts.Items.Add(name); item.SubItems.Add(enabled); if (fetchAccount.Enabled) { item.SubItems.Add(fetchAccount.NextDownloadTime); } item.Tag = fetchAccount.ID; Marshal.ReleaseComObject(fetchAccount); } }
private void buttonDeleteExternalAccount_Click(object sender, EventArgs e) { hMailServer.FetchAccounts fetchAccounts = _representedAccount.FetchAccounts; foreach (ListViewItem item in listFetchAccounts.SelectedItems) { int id = Convert.ToInt32(item.Tag); fetchAccounts.DeleteByDBID(id); } Marshal.ReleaseComObject(fetchAccounts); ListExternalAccounts(); }
private void buttonAddExternalAccount_Click(object sender, EventArgs e) { formExternalAccount externalAccountDialog = new formExternalAccount(); if (externalAccountDialog.ShowDialog() == DialogResult.OK) { hMailServer.FetchAccounts fetchAccounts = _representedAccount.FetchAccounts; hMailServer.FetchAccount fetchAccount = _representedAccount.FetchAccounts.Add(); Marshal.ReleaseComObject(fetchAccounts); externalAccountDialog.SaveAccountProperties(fetchAccount); fetchAccount.Save(); Marshal.ReleaseComObject(fetchAccount); ListExternalAccounts(); } }