Create rules using lotus script

Hello All!

Does anyone have a sample code for create a mail rule using lotus script?

I need to create a rule on all mailboxes on the server but our users are not skilled…

I have to send a mail with an hotspot button that if clicked create a rule.

Thanks a lot!

Umberto

Subject: create rules using lotus script

In Notes all these things are documents:

Create a rule in a mail database that is accessible by all users.

Find the Noteid/UNID for that document (from Document Properties)

Write code that when activated will:

  • Open this database/document

  • Create a copy in the target database

VOILA!!

Subject: and yet this will not work

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

Mail rule issues with Notes/Domino mail template

Subject: RE: create rules using lotus script

Thanks al lot!I’ll try this solution.

Umberto

Subject: RE: create rules using lotus script

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)

End Sub