hMailServer.Administrator.ucAntiVirus.buttonAddBlockedAttachment_Click C# (CSharp) Method

buttonAddBlockedAttachment_Click() private method

private buttonAddBlockedAttachment_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        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();
        }