There are a number of technotes which describe the data structures which define rules. (Namely, the Rule documents in the Rules view, and the associated $FilterFormula items in the Calendar Profile document.) Programmtically adding Rule documents to a mail file will not cause the necessary associated $FilterFormula items to be created, so the rules will not work. Also, the OrderNum item in the Rule document must be set correctly as well.
These are things which are done by the client when the user edits, saves, enables, disables, or re-orders one or more Rules. These extra steps that the client performs in the background must be taken into account if attempting to work with Rules programmatically.
Here are some possibly useful inks:
How to copy mail rules to another database
Deleted mail rules still run and/or enabled mail rules do not run
I’ve tried this code, this give me no error, but i can’t see the rule in my database.Rules.nsf is created from “mail6.ntf” and all users have “manager access”, when I run the agent the client is working for a few second and is all, in rules view I have nothig.
I’ve also changed the $KeepPrivate flag to 0 in Rules.nsf document…
this is the code:
Sub Initialize
Dim ses As New notessession
Dim docFrom As notesdocument
Dim docTo As notesdocument
Dim dbFrom As notesdatabase
Dim dbTo As notesdatabase
Set dbTo=ses.CurrentDatabase
Set dbFrom= New NotesDatabase("MyServer","Rules.nsf")
Set docFrom = dbFrom.GetDocumentByUNID("E1085801AADD2E65C12575050027BCA2")
Set docTo = docFrom.CopyToDatabase(dbTo)