private void buttonDeleteBlockedAttachment_Click(object sender, EventArgs e) { if (!Utility.AskDeleteItems()) { return; } hMailServer.Settings settings = APICreator.Settings; hMailServer.AntiVirus antiVirusSettings = settings.AntiVirus; hMailServer.BlockedAttachments attachments = antiVirusSettings.BlockedAttachments; List <ListViewItem> itemsToRemove = new List <ListViewItem>(); foreach (ListViewItem item in listBlockedAttachments.SelectedItems) { int id = Convert.ToInt32(item.Tag); attachments.DeleteByDBID(id); itemsToRemove.Add(item); } foreach (ListViewItem item in itemsToRemove) { listBlockedAttachments.Items.Remove(item); } Marshal.ReleaseComObject(settings); Marshal.ReleaseComObject(antiVirusSettings); Marshal.ReleaseComObject(attachments); }
private void EditSelectedBlockedAttachment() { if (listBlockedAttachments.SelectedItems.Count < 0) { return; } int id = Convert.ToInt32(listBlockedAttachments.SelectedItems[0].Tag); hMailServer.Settings settings = APICreator.Settings; hMailServer.AntiVirus antiVirusSettings = settings.AntiVirus; hMailServer.BlockedAttachments attachments = antiVirusSettings.BlockedAttachments; hMailServer.BlockedAttachment ba = attachments.get_ItemByDBID(id); formBlockedAttachment blockedDlg = new formBlockedAttachment(); blockedDlg.LoadProperties(ba); if (blockedDlg.ShowDialog() == DialogResult.OK) { blockedDlg.SaveProperties(ba); ba.Save(); } Marshal.ReleaseComObject(settings); Marshal.ReleaseComObject(antiVirusSettings); Marshal.ReleaseComObject(attachments); Marshal.ReleaseComObject(ba); ListBlockedAttachments(); }
private void DeleteEnvironment() { while (_application.Domains.Count > 0) { _application.Domains[0].Delete(); } hMailServer.WhiteListAddresses addresses = _application.Settings.AntiSpam.WhiteListAddresses; while (addresses.Count > 0) { addresses[0].Delete(); } hMailServer.Routes routes = _application.Settings.Routes; while (routes.Count > 0) { routes[0].Delete(); } hMailServer.BlockedAttachments attachments = _application.Settings.AntiVirus.BlockedAttachments; while (attachments.Count > 0) { attachments[0].Delete(); } hMailServer.DNSBlackLists blackLists = _application.Settings.AntiSpam.DNSBlackLists; while (blackLists.Count > 0) { blackLists[0].Delete(); } hMailServer.SURBLServers surblServers = _application.Settings.AntiSpam.SURBLServers; while (surblServers.Count > 0) { surblServers[0].Delete(); } hMailServer.SSLCertificates sslCertificates = _application.Settings.SSLCertificates; while (sslCertificates.Count > 0) { sslCertificates[0].Delete(); } hMailServer.IncomingRelays incomingRelays = _application.Settings.IncomingRelays; while (incomingRelays.Count > 0) { incomingRelays[0].Delete(); } }
private void ConfirmBlockedAttachments() { hMailServer.BlockedAttachments attachments = _application.Settings.AntiVirus.BlockedAttachments; Assert.Greater(attachments.Count, 0); for (int i = 0; i < attachments.Count; i++) { hMailServer.BlockedAttachment ba = attachments[i]; if (ba.Description == "My description" && ba.Wildcard == "*.my") { return; } } Assert.Fail("Blocked attachment not found"); }
private void buttonAddBlockedAttachment_Click(object sender, EventArgs e) { formBlockedAttachment blockedDlg = new formBlockedAttachment(); if (blockedDlg.ShowDialog() == DialogResult.OK) { hMailServer.Settings settings = APICreator.Application.Settings; hMailServer.AntiVirus antiVirusSettings = settings.AntiVirus; hMailServer.BlockedAttachments attachments = antiVirusSettings.BlockedAttachments; hMailServer.BlockedAttachment ba = attachments.Add(); blockedDlg.SaveProperties(ba); ba.Save(); Marshal.ReleaseComObject(ba); Marshal.ReleaseComObject(settings); Marshal.ReleaseComObject(antiVirusSettings); Marshal.ReleaseComObject(attachments); } ListBlockedAttachments(); }
private void ListBlockedAttachments() { listBlockedAttachments.Items.Clear(); hMailServer.Settings settings = APICreator.Application.Settings; hMailServer.AntiVirus antiVirusSettings = settings.AntiVirus; hMailServer.BlockedAttachments attachments = antiVirusSettings.BlockedAttachments; for (int i = 0; i < attachments.Count; i++) { hMailServer.BlockedAttachment attachment = attachments[i]; ListViewItem item = listBlockedAttachments.Items.Add(attachment.Wildcard); item.SubItems.Add(attachment.Description); item.Tag = attachment.ID; Marshal.ReleaseComObject(attachment); } Marshal.ReleaseComObject(settings); Marshal.ReleaseComObject(antiVirusSettings); Marshal.ReleaseComObject(attachments); }