E-Mail "Iconizing" Agent

An Agent to attach an icon to incoming e-mail according to user-set rules (the agent is designed so that it can also be run on selected documents). The agent includes a function, SetIcon, that takes a field-name, a regular-expression, and an icon number. If the field's contents match against the pattern then the e-mail gets the requested icon. The Initialize function is used to call SetIcon for each rule (and also to loop over all selected documents). If a rule succeeds Initialize exits or jumps to the next document (this allows the user to put the highest priority rules first). The technique can be also used to move the e-mail to a folder or other similar activities. This agent is much better than setting a different agent for each rule and using a "By Field" search criterion because the regular-expression match is much more powerful than "By Field", and because you can centralize & prioritize the rules (cannot be done with separate agents). It is also much less resource-intensive.

Private Function SetIcon ( doc As NotesDocument, fldnam$, pattern$, iconno% )
As Integer
fldvals = doc.GetItemValue(fldnam$)
Forall fldval In fldvals
If fldval Like pattern$ Then
Set rc = doc.ReplaceItemValue("_ViewIcon",iconno%)
doc.Save False,False,False
SetIcon% = True
Exit Function
End If
End Forall
SetIcon% = False
End Function

Sub Initialize

Dim sess As New NotesSession
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument

Set coll = sess.CurrentDatabase.UnprocessedDocuments
Set doc = coll.GetFirstDocument

Do While Not(doc Is Nothing)


If doc.HasItem("_ViewIcon") Then Exit Do

If SetIcon%(doc,"SendTo","*joke*",96) Then Exit Do
If SetIcon%(doc,"Subject","*joke*",96) Then Exit Do

'MVS, OE, S/390 mailing lists
If SetIcon%(doc,"SendTo","*MVS[-]OE*",98) Then Exit Do
If SetIcon%(doc,"CopyTo","*MVS[-]OE*",98) Then Exit Do
If SetIcon%(doc,"SendTo","*DOM390[-]L*",98) Then Exit Do
If SetIcon%(doc,"CopyTo","*DOM390[-]L*",98) Then Exit Do

If SetIcon%(doc,"SendTo","*NTBUGTRAQ[@]*",99) Then Exit Do
If SetIcon%(doc,"CopyTo","*NTBUGTRAQ[@]*",99) Then Exit Do
If SetIcon%(doc,"SendTo","*NTSECURITY[@]*",100) Then Exit Do
If SetIcon%(doc,"CopyTo","*NTSECURITY[@]*",100) Then Exit Do

'News digests
If SetIcon%(doc,"From","*computerworld_daily*",117) Then Exit Do
If SetIcon%(doc,"From","*anchordesk*",117) Then Exit Do
If SetIcon%(doc,"From","*zdnet[_]update*",117) Then Exit Do
If SetIcon%(doc,"SendTo","*DailyNews*",117) Then Exit Do
If SetIcon%(doc,"From","*news[@]*informationweek.com*",117) Then
Exit Do

'private mail
If SetIcon%(doc,"SendTo","*nimrod*",85) Then Exit Do
If SetIcon%(doc,"CopyTo","*nimrod*",85) Then Exit Do

Loop While False

Set doc = coll.GetNextDocument(doc)


End Sub

This was last published in November 2000

Dig Deeper on Domino Resources - Part 4

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...