Domino 9 und frühere Versionen > ND6: Administration & Userprobleme

Rules

<< < (2/2)

Andy B:

Subject: Create a mail rule in script

Posted by Alexandre Guerard on 30.07.2004 at 20:41 using a Web browser

Category: Domino Designer  Release: 6.5  Platform: Windows 2000

Content:
Hi,

I want to create a mail rule using script when the database is open.

The script bellow verify if the Rules already exist and create if not.

1) In the Database Script, I verify if the rule exist and if not, I create the document

2) I pass the new Doc and I run the same code as the OK button in the New rules form. Call ButtonOKClient()

The rules get created but the problem is that it doesn't work.

Thank You
Alexandre

Database SCRIPT (Initialize):

Call SCISetJunkRule()

Sub SCISetJunkRule:

Sub SCISetJunkRule()
'// Verify if rules exist
 Dim m_Session As New notessession
 Dim m_Db As notesdatabase 
 Dim ViewEntry As Notesviewentry
 Dim m_RulesView As notesview
 Dim m_ViewCollection As NotesViewEntryCollection
 Dim  m_RuleDoc As notesdocument
 Dim doc As NotesDocument
 
 Set m_db = m_Session.currentdatabase
 Set m_RulesView = m_Db.getview("Rules")
 
 If m_RulesView Is Nothing Then Exit Sub
 Set m_ViewCollection = m_RulesView.Allentries
 If m_ViewCollection.count > 0 Then
  Set ViewEntry = m_ViewCollection.Getfirstentry
  While Not ViewEntry Is Nothing
   Set doc = ViewEntry.Document   
   If Instr(doc.ConditionList(0),"[SPAM]") <> 0 Then
    Exit Sub
   End If
   Set ViewEntry = m_ViewCollection.Getnextentry(  ViewEntry  )
  Wend
 End If
 
 '//Find Highest Rules
 Dim Highest As Integer
 
 If m_RulesView Is Nothing Then Exit Sub
 Highest = 0
 Set m_ViewCollection = m_RulesView.Allentries
 If m_ViewCollection.count > 0 Then
  Set ViewEntry = m_ViewCollection.Getfirstentry
  While Not ViewEntry Is Nothing
   If highest < ViewEntry.Columnvalues( 1 ) Then
    Highest = Cint( ViewEntry.Columnvalues( 1 ) )
   End If
   Set ViewEntry = m_ViewCollection.Getnextentry(  ViewEntry  )
  Wend
 End If
 If Highest = 0 Then
  Highest = 1
 End If
 
 
'// Create rules
 Dim exclude(1) As String
 Dim FilterFormulaItem As NotesItem
 Dim  m_CalProfile As NotesDocument
 Set m_CalProfile = m_db.GetProfileDocument("CalendarProfile")
 Set FilterFormulaItem = m_CalProfile.getfirstitem("$FilterFormula")
 
 If m_CalProfile Is Nothing Then
  Exit Sub
 End If
 
 exclude(0)="A"
 exclude(1)="D"
 
 Set m_RuleDoc = m_Db.CreateDocument
 Call m_RuleDoc.ReplaceItemValue("Form","Mailrule")
 Call m_RuleDoc.ReplaceItemValue("action","1")
 Call m_RuleDoc.ReplaceItemValue("condition","1")
 Call m_RuleDoc.ReplaceItemValue("logic","1")
 Call m_RuleDoc.ReplaceItemValue("Type","1")
 Call m_RuleDoc.ReplaceItemValue("TokActionList","1|1|($JunkMail)")
 Call m_RuleDoc.ReplaceItemValue("tokConditionList","2|1|[SPAM]|0")
 Call m_RuleDoc.ReplaceItemValue("inportance","1")
 Call m_RuleDoc.ReplaceItemValue("importancecond","1")
 Call m_RuleDoc.ReplaceItemValue("operator","0")
 Call m_RuleDoc.ReplaceItemValue("ExpireDates","D")
 Call m_RuleDoc.ReplaceItemValue("ExpireNumber","5")
 Call m_RuleDoc.ReplaceItemValue("ConditionList", " Subject contains [SPAM]")
 Call m_RuleDoc.ReplaceItemValue("ActionList"," move to folder ($JunkMail)")
 Call m_RuleDoc.ReplaceItemValue("ExcludeFromView",exclude)
 Call m_RuleDoc.ReplaceItemValue("$FilterFormula","")
 Call m_RuleDoc.ReplaceItemValue("$NoPurge","")
 Call m_RuleDoc.ReplaceItemValue("Enable", "1")
 Call m_RuleDoc.ReplaceItemValue("PROTECTFROMARCHIVE", "1")
 Call m_RuleDoc.ReplaceItemValue("OrderNum",Highest)   
 Call m_RuleDoc.ComputeWithForm(False,False)
 
 Dim ws As New NotesUIWorkspace
 Dim uidoc As notesuidocument
 Set  uidoc = ws.editdocument(True,m_RuleDoc)
 Call SaveRule(m_RuleDoc, uidoc)

End Sub

Script Library - Function SaveRule

Function SaveRule (m_RuleDoc As NotesDocument, m_uidoc As NotesUIDocument) As String 
 Set note = m_RuleDoc
 Set uidoc = m_uidoc
 Call ButtonOKClient()
End function

tttonic:
Mmmmh.

warum kann ich in dem o.a. Script eine Rule erstellen lassen indem Sonderzeichen drin sind?
Wenn ich eine normale rule erstelle ist dieses doch nicht möglich.
Das geht nur in einer Quick-Rule, komischerweise.

Andy B:
Ob das Script am ende läuft oder nicht, kann ich nicht sagen. Ich habe für dich das Script gesucht und hir gepostet.
Meine Meinung zu einem solchen Script kennst Du ja.

Gruss
Andy B

tttonic:

--- Zitat von: Andy B am 17.02.05 - 11:31:39 ---Ob das Script am ende läuft oder nicht, kann ich nicht sagen. Ich habe für dich das Script gesucht und hir gepostet.
Meine Meinung zu einem solchen Script kennst Du ja.

Gruss
Andy B



--- Ende Zitat ---

Verzeich, aber das steht doch nun überhaupt nicht im Zusammenhang mit meinem Kommentar .

Navigation

[0] Themen-Index

[*] Vorherige Sete

Zur normalen Ansicht wechseln