Creating Mail Rules in script - $FilterFormula Field

I am creating a mail rule in script. WeOur spam filtering puts the text ‘spam’ in the subject of spammy emails. basically, i have a button on our Memo form whose logic states, if ‘spam’ is in the subject, and a rule hasn’t already been created to do so, create a rule that says if subject contains ‘spam’ then send mail to JunkMail folder. The rule is created successfully and a comparison of the script created ule and a regular rule created in the rules view shows only one discrepancy - the $FilterFormula field is encoded in the regular rule and it simply shows the SELECT formula (unencoded) in my script-created rule. How can I get this field to encode?

All I’m doing when the user selects the button in the memo form is calling the same script libraries that the OK button in the mailrule form calls (not the same, actually, but i made copies of the chain of script libraries that are called by the OK button and I’m calling those). No errors, the rule appears to be fine and it’s enabled, but it doesn’t work and it seems to be due to the fact the $FilterFormula is computing incorrectly. I deleted my CalendarProfile and recreated it, so that’s not it. Any suggestions???

Subject: creating Mail Rules in script - $FilterFormula Field

I am the developer of a product which will allow you to do this for any/all mailfiles on a system if you’re interested. You can sync a common set of rules to a number of mailfiles on a scheduled basis. It also significantly extended the type and function of rules that you can use. My email is in my profile.

Subject: creating Mail Rules in script - $FilterFormula Field

I created a similar button to block SPAM and had the same problem. To get this to work, I had to edit and close the mailrule document.

I have this…

Dim ruleDoc as notesuidocument

Dim doc as notesdocument

Set doc = new notesdocument(db)

doc.From = “MailRule”

// Set the other fields

Set ruleDoc = ws.editdocument(True,doc,) // the doc is the instance of the backend rule doc.

call ruleDoc.save

call ruleDoc.close

set doc = ruleDoc.Document.

// Use the instance doc to retrieve and set values in the calendar profile.

This stores the $$FilterFormula in the correct format.

You can then take the value and store it in the Calendar Profile and update the $$FilterFormulaCount in the calendar profile.

The only drawback is that for a split second the user will see a window open and close. To offset that I am displaying a message box to the user indicating that all future messages from the user will be blocked.

Subject: RE: creating Mail Rules in script - $FilterFormula Field

I’m trying to accomplish the same process but using the post-open event to make sure a specific rule is in place in the mailfile. Do you have a script example you could share?