Whitelisting - Partial Solution - Need help finishing please

Hi all. After reading tons of posts in this forum and other notes forums about blacklisting, it seems that whitelisting is a much better fit for our company. I found a couple of great threads with some posted code that I took and modified. The first thread was here → http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/6e4f2e6aa89587c685256d420050feb8?OpenDocument Instead of looking at the RBL tag and determining if it’s SPAM that way, I reversed the logic in it and had it look if the email contained the SMTPOriginator field. If it did, I then went through the logic of seeing if it was whitelisted in the user’s calendar profile and took action on it bases on that. Here is the code after I made my changes to it.Sub Initialize

Dim Session As NotesSession

Dim DB As NotesDatabase

Dim doc As notesdocument

Dim docProfile As NotesDocument

Dim strAction As String

Dim strFolder As String



Set Session = New NotesSession

Set doc = Session.DocumentContext



If doc.HasItem("SMTPOriginator") Then

REM Current Mail is marked as Spam

	Set DB = Session.CurrentDatabase

REM Get Mail Preferences with Spam Settings

	Set docProfile = db.GetProfileDocument("CalendarProfile")

	If Not docProfile Is Nothing Then

REM Check whether sender is listed in personal Whitelist

		If Not IsInWhiteList(db, doc, docProfile) Then

REM Get selected Action

			strAction = ""

			If docProfile.HasItem("SpamOptionsTX") Then

				strAction = docProfile.SpamOptionsTX(0)

			End If

			Select Case strAction

			Case "M" 'Move to a folder

				strFolder = "Spam"

REM Get Folder name

				If docProfile.HasItem("SpamFolderTX") Then

					strFolder = docProfile.SpamFolderTX(0)

					If strFolder = "" Then

						strFolder = "Spam"

					End If

				End If

REM Move document to folder

				Call doc.PutInFolder(strFolder,True)

				Call doc.RemoveFromFolder( "($Inbox)" )

			Case "D" 'Delete document immediately

				Call doc.Remove(True)

			End Select

		End If

	End If

End If

End Sub

and the Function…

Function IsInWhiteList(DB As NotesDatabase, Doc As NotesDocument, docProfile As NotesDocument) As Integer

IsInWhiteList = False



Dim docWhiteList As NotesDocument

Dim strFrom As String

Dim strTemp As String



If doc.HasItem("SMTPOriginator") Then

	strFrom = Ucase(doc.SMTPOriginator(0))

Else

REM This is not an SMTP Message

	Exit Function

End If



If strFrom = "" Then

	If doc.HasItem("From") Then

		strFrom = Ucase(doc.From(0))

	Else

REM Unable to determine the sender

		Exit Function

	End If

End If



Forall strAllowed In docProfile.SpamWhiteListTX

	If strAllowed <> "" Then

REM WhiteList may contain complete mail addresses like ‘John@domain.com’ …

		If Instr(strAllowed, "@") > 0 Then

			If Ucase(strAllowed) = strFrom Then

				IsInWhiteList = True

				Exit Forall

			End If

		Else

REM … or just domain names like ‘domain.com

			strTemp = Mid$(strFrom, Instr(strFrom, "@")+1)

			If Ucase(strTemp) = Ucase(strAllowed) Then

				IsInWhiteList = True

				Exit Forall

			End If

		End If

	End If

End Forall

End Function

This worked great! Once a user feels that everyone is in their whitelist, they can just change the option in the profile to Delete instead of Move.

Here is where I need help on…

Upper Management wants to be able to check a master whitelist first before checking the user’s whitelist. This led me to this thread->

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/ceaccb7e8ce30b6985256d0200492b47?OpenDocument

What I would like to happen is for the email to come in, and the Process Spam agent kicks off before new mail arrives. It first checks the profile document in the master whitelist and if found, sends the email to the user’s Inbox. If the email sender/domain is not found, it then checks the user’s CalendarProfile and if in the user’s whitelist, send to Inbox, if not, send to the JunkMail folder, or whatever option they have selected.

Sorry for the long post, I just felt that I had to be very detailed in what I was needing help with. Once I get this working, I will either post it in this thread or create a database and submit it to the sandbox, as this seems to be something that a lot of people could use.

TIA,

Clint