
AGENT
Mail rules for POP mail
Thomas Ozenne 12.09.2002
Rating: -3.00- (out of 5)




|
Each day I get mail from pop accounts to my mail box , but as you may have noticed Mail Rules are applied on the Domino Router not in Mail dbs , to have Lotus Process my rules for the non server incoming mail I did setup a small agent which if able to process simples rules ( multiple Field contains selection & single Action move to folder ...). Paste the code in a new agent in your mail db have it run against all new modified documents and here you go:
Code
Sub Initialize
'This scrip will process locally Simple mail rules based on a condition and simple Move to folder actions
'Works with R6 mail template english , should work in R5
'For other language this would require a few more Replacesubstrings
Dim lang As String
lang = "move to folder"
Dim s As notessession
Dim db As notesdatabase
Set db = New notesdatabase("","")
Dim vue As notesview
Set vue = db.GetView("(Rules)")
Dim inbox As notesview
Set inbox = db.GetView("($Inbox)")
Dim mrules As notesdocument
Dim valu As String
Dim qry As String
Dim temp As Variant
Dim col2 As notesdocumentcollection
Set mrules = vue.GetFirstDocument
If mrules Is Nothing Then
Print "No rule to process"
Exit Sub
End If
Do While Not mrules Is Nothing
If Instr(mrules.actionlist(0),lang)>0 Then
movefolder= Trim(Strrightback(mrules.actionlist(0),lang))
qry = ""
Forall a In mrules.conditionlist
valu = {temp:=@ReplaceSubstring("} & a & {";"Sender";"FROM");@If(@Contains(temp;"AND");" AND "+@ReplaceSubstring(temp;"AND";"Field ");@Contains(val;"OR");" OR "+@ReplaceSubstring(temp; "OR";"Field ");"Field " + temp)}
temp =Evaluate(valu)
qry = qry & " " & temp(0)
End Forall
Set col2 = db.Ftsearch(qry, 0, 0)
If col2.Count > 0 Then
Call col2.PutAllInFolder(movefolder,False)
Call col2.RemoveAllFromFolder("($Inbox)")
End If
End If
Set mrules = vue.GetNextDocument(mrules)
Loop
End Sub
 |

|
|
 |
|
 |