hMailServer.Administrator.ucGreyListing.buttonAddWhiteList_Click C# (CSharp) Method

buttonAddWhiteList_Click() private method

private buttonAddWhiteList_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void buttonAddWhiteList_Click(object sender, EventArgs e)
        {
            formGreyListingWhiteAddress whiteDlg = new formGreyListingWhiteAddress();

            if (whiteDlg.ShowDialog() == DialogResult.OK)
            {
                hMailServer.Application app = APICreator.Application;
                hMailServer.Settings settings = app.Settings;
                hMailServer.AntiSpam antiSpamSettings = settings.AntiSpam;
                hMailServer.GreyListingWhiteAddresses greyListingWhiteAddresses = antiSpamSettings.GreyListingWhiteAddresses;
                hMailServer.GreyListingWhiteAddress whiteAddress = greyListingWhiteAddresses.Add();

                whiteDlg.SaveProperties(whiteAddress);
                whiteAddress.Save();

                Marshal.ReleaseComObject(settings);
                Marshal.ReleaseComObject(antiSpamSettings);
                Marshal.ReleaseComObject(greyListingWhiteAddresses);
                Marshal.ReleaseComObject(whiteAddress);

                ListWhiteListAddresses();
            }
        }