Exemplo n.º 1
0
        private void CreateMessageModificationRule(hMailServer.Rules ruleContainer)
        {
            Rule rule = ruleContainer.Add();

            rule.Name   = "Criteria test";
            rule.Active = true;

            RuleCriteria ruleCriteria = rule.Criterias.Add();

            ruleCriteria.UsePredefined   = true;
            ruleCriteria.PredefinedField = eRulePredefinedField.eFTMessageSize;
            ruleCriteria.MatchType       = eRuleMatchType.eMTGreaterThan;
            ruleCriteria.MatchValue      = "0";
            ruleCriteria.Save();

            RuleAction ruleAction = rule.Actions.Add();

            ruleAction.Type           = eRuleActionType.eRARunScriptFunction;
            ruleAction.ScriptFunction = "ModifyMessage";
            ruleAction.Save();

            rule.Save();

            File.WriteAllText(_settings.Scripting.CurrentScriptFile,
                              "Sub ModifyMessage(message)" + Environment.NewLine +
                              "message.Subject = \"[Spam] \" + CStr(message.Subject)" + Environment.NewLine +
                              "message.Save" + Environment.NewLine +
                              "End Sub");

            _settings.Scripting.Reload();
        }
Exemplo n.º 2
0
        private void CreateMoveRule(hMailServer.Rules ruleContainer, string foldername)
        {
            Rule rule = ruleContainer.Add();

            rule.Name   = "Criteria test";
            rule.Active = true;

            RuleCriteria ruleCriteria = rule.Criterias.Add();

            ruleCriteria.UsePredefined   = true;
            ruleCriteria.PredefinedField = eRulePredefinedField.eFTMessageSize;
            ruleCriteria.MatchType       = eRuleMatchType.eMTGreaterThan;
            ruleCriteria.MatchValue      = "0";
            ruleCriteria.Save();

            RuleAction ruleAction = rule.Actions.Add();

            ruleAction.Type       = eRuleActionType.eRAMoveToImapFolder;
            ruleAction.IMAPFolder = foldername;
            ruleAction.Save();

            rule.Save();
        }