コード例 #1
0
        private void AddIPRange()
        {
            hMailServer.SecurityRange oRange = _ipRanges.Add();
            oRange.LowerIP = "127.0.0.1";
            oRange.UpperIP = "127.0.0.1";
            oRange.Name    = "My computer";
            oRange.AllowDeliveryFromLocalToLocal  = true;
            oRange.AllowDeliveryFromLocalToRemote = true;
            oRange.AllowDeliveryFromRemoteToLocal = true;
            oRange.AllowIMAPConnections           = true;
            oRange.AllowPOP3Connections           = true;
            oRange.AllowSMTPConnections           = true;


            oRange.EnableSpamProtection = true;

            oRange.Save();
        }
コード例 #2
0
ファイル: ucIPRange.cs プロジェクト: radtek/hMailServer
        public bool SaveData()
        {
            bool newObject = false;

            if (_representedObject == null)
            {
                hMailServer.Application    app            = APICreator.Application;
                hMailServer.Settings       settings       = app.Settings;
                hMailServer.SecurityRanges securityRanges = settings.SecurityRanges;
                _representedObject = securityRanges.Add();

                newObject = true;

                Marshal.ReleaseComObject(settings);
                Marshal.ReleaseComObject(securityRanges);
            }

            _representedObject.Name     = textName.Text;
            _representedObject.Priority = textPriority.Number;

            _representedObject.LowerIP = textLowerIPAddress.Text;
            _representedObject.UpperIP = textUpperIPAddress.Text;

            _representedObject.AllowSMTPConnections = checkAllowSMTP.Checked;
            _representedObject.AllowPOP3Connections = checkAllowPOP3.Checked;
            _representedObject.AllowIMAPConnections = checkAllowIMAP.Checked;

            _representedObject.RequireSMTPAuthLocalToLocal       = checkRequireSMTPAuthLocalToLocal.Checked;
            _representedObject.RequireSMTPAuthLocalToExternal    = checkRequireSMTPAuthLocalToExternal.Checked;
            _representedObject.RequireSMTPAuthExternalToLocal    = checkRequireSMTPAuthExternalToLocal.Checked;
            _representedObject.RequireSMTPAuthExternalToExternal = checkRequireSMTPAuthExternalToExternal.Checked;

            _representedObject.AllowDeliveryFromLocalToLocal   = checkAllowDeliveiesFromL2L.Checked;
            _representedObject.AllowDeliveryFromLocalToRemote  = checkAllowDeliveiesFromL2R.Checked;
            _representedObject.AllowDeliveryFromRemoteToLocal  = checkAllowDeliveiesFromR2L.Checked;
            _representedObject.AllowDeliveryFromRemoteToRemote = checkAllowDeliveiesFromR2R.Checked;

            _representedObject.EnableSpamProtection = checkSpamProtection.Checked;
            _representedObject.EnableAntiVirus      = checkAntiVirus.Checked;

            _representedObject.Expires     = checkExpires.Checked;
            _representedObject.ExpiresTime = dateTimeExpiresTime.Value;

            try
            {
                _representedObject.Save();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }


            // Refresh the node in the tree if the name has changed.
            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(checkExpires.Checked ? Color.Red : Color.Black, textName.Text);

            // Set the object to clean.
            DirtyChecker.SetClean(this);

            if (newObject)
            {
                SearchNodeText crit = new SearchNodeText(_representedObject.Name);
                mainForm.SelectNode(crit);
            }

            return(true);
        }