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);
}