Subject: Moving pre-tagged spam to ($JunkMail)
For the record, we finally went for a “before new mail arrives” agent.
Whenever the incoming message is supposed to be a spam, we put it in the junkmail folder remove it from both the Inbox folder and the All documents view.
Then we customized the Junkmail folder :
-
added a “[SPAM]” string before the subject, to make spam messages stand out of other junk mails
-
added a Restore button and a QueryAddToFolder event, so that users can revive a legitimate message
The only issue now is that Ironport won’t disclose the messages’ spam score (it’s stored encrypted – they consider it a trade secret), so we can’t adjust the spam thresold on the appliance based on user feedback as we hoped to, and we’re stuck with the default settings.
They offered to disclose the scores on a message by messages basis and we had very few false postives so far, so maybe it won’t be so problematic.
Here’s the “before new mail arrives” agent code :
Sub Initialize
' Classement automatique du spam présumé
' Le message reçu est:
' - placé dans le dossier Courrier indésirable ($JunkMail)
' - retiré du dossier Courrier en arrivée ($Inbox)
' - exclu de la vue Tous documents ($All)
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc = session.DocumentContext
If Ucase (Left (doc.X_Spam_Status(0), 3)) = "YES" Then
doc.GetFirstItem ("X_Spam_Status").IsSummary = True
doc.PutInFolder "($JunkMail)"
doc.RemoveFromFolder "($Inbox)"
doc.ExcludeFromView = "A"
doc.Save True, True
End If
End Sub
NB: We had to flag the X_Spam_Status field as a SUMMARY field, otherwise it can’t be used in the Subject column’s formula.
Here’s the Restore button code :
Sub Click(Source As Button)
' Sortie de document(s) du dossier $JunkMail
'
' Si le champ ExcludeFromView existe et contient "A"
' (message classé automatiquement par l'agent "Filtre anti-spam"),
' on retire cette valeur.
Const EFV = "ExcludeFromView"
Const ALL = "A"
Dim session As New NotesSession
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim v
Dim uiw As New NotesUIWorkspace
Set coll = session.CurrentDatabase.UnprocessedDocuments
Set doc = coll.GetFirstDocument
While Not doc Is Nothing
If doc.HasItem (EFV) Then
v = doc.GetItemValue (EFV)
If Not Isnull (Arraygetindex (v, ALL)) Then
v = Fulltrim (Arrayreplace (v, ALL, Null))
doc.ReplaceItemValue EFV, v
doc.Save True, True
End If
End If
Set doc = coll.GetNextDocument (doc)
Wend
coll.PutAllInFolder "($Inbox)", False
coll.RemoveAllFromFolder "($JunkMail)"
uiw.ViewRefresh
End Sub
And at last, here’s the QueryAddToFolder code :
Sub Queryaddtofolder(Source As Notesuiview, Target As Variant, Continue As Variant)
' Sortie de document(s) du dossier $JunkMail
'
' Si le champ ExcludeFromView existe et contient "A"
' (message classé automatiquement par l'agent "Filtre anti-spam"),
' on retire cette valeur.
Const EFV = "ExcludeFromView"
Const ALL = "A"
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim v
Set coll = Source.Documents
Set doc = coll.GetFirstDocument
While Not doc Is Nothing
If doc.HasItem (EFV) Then
v = doc.GetItemValue (EFV)
If Not Isnull (Arraygetindex (v, ALL)) Then
v = Fulltrim (Arrayreplace (v, ALL, Null))
doc.ReplaceItemValue EFV, v
doc.Save True, True
End If
End If
Set doc = coll.GetNextDocument (doc)
Wend
End Sub
I hope someone will find this useful. 