|
|
|
|
|
|
|
|
|
|
|
|
|
|
EMAIL MANAGEMENT
Add convenience to your spam blocker
By Kai Wilzer
In my previous two articles I introduced the topic of fighting spam within your Domino environment. If you've followed along from the beginning, we've already discussed the definition of spam and how to block it. All the basics are implemented, so a large amount of spam should be filtered right now. In this last article, we'll look at how to add more convenience for our end users.
Convenient addition to the personal Whitelist In the last article, we implemented a personal spam whitelist. For additional information on this topic, be sure to check out Chris Harvey's agent to process tagged spam at http://chris.brotherhoodmutual.com/dev/adminotes.nsf/plinks/CRHY-5M3QUJ.
In our current implementation, the user has to add addresses or domains manually. Of course, it would be more convenient if we have a button in the spam mail to automatically add the sender or his domain to the personal Whitelist. The button should work on both a view selecting one or more documents and within a single document.
Open your Mail template and create a new agent. Select the option to run manually from the agent list on selected documents. Select LotusScript and add the following code.
Const SpamWhiteList ="SpamWhiteListTX"
Const DNSBLSite = "$DNSBLSite"
Sub Initialize
Dim Session As notessession
Dim DB As NotesDatabase
Dim coll As NotesDocumentCollection
Dim UIWs As NotesUIWorkspace
Dim UIDoc As NotesUIDocument
Dim doc As NotesDocument
Dim docProfile As NotesDocument
Dim intChoice As Integer
Dim strFrom As String
Dim strDomain As String
Dim item As NotesItem
Dim boolFound As Integer
Set Session = New NotesSession
Set DB = Session.CurrentDatabase
Set docProfile = db.GetProfileDocument("CalendarProfile")
If docProfile Is Nothing Then
Messagebox "There is currently no profile for your mailfile available. Please click 'Tools' 'Preferences' "+_
"to create a new profile.", 16, "Unable to find profile"
Exit Sub
End If
If docProfile.HasItem(SpamWhiteList) Then
Set item = docProfile.GetFirstItem(SpamWhitelist)
Else
Set item = New NotesItem(docProfile, SpamWhiteList, "")
End If
REM Agent may be called from view or UIDocument
Set coll = DB.UnprocessedDocuments
If coll.Count = 0 Then
Set UIWs = New NotesUIWorkspace
Set UIDoc = UIWs.CurrentDocument
If Not UIDoc Is Nothing Then
Set doc = UIDoc.Document
Set coll = Nothing
Call coll.AddDocument(doc)
End If
End If
If coll.Count = 0 Then
Messagebox "Please select the sender you want to add to your Spam Whitelist.", 64, "No documents selected"
Exit Sub
End If
Set doc = coll.GetFirstDocument
Do While Not doc Is Nothing
If Not doc.HasItem(DNSBLSite) Then
Messagebox "The selected document is not flagged as Spam Message. Therefor it's not necessary to "+_
"add the sender to your Spam Whitelist.", 64, "No need to update Whitelist"
Else
If doc.HasItem("SMTPOriginator") Then
strFrom = doc.SMTPOriginator(0)
Else
strFrom = ""
End If
If strFrom = "" Then
If doc.HasItem("From") Then
strFrom = doc.From(0)
End If
End If
If strFrom = "" Then
Messagebox "The sender of the mail could not be identified with fields 'SMTPOriginator' and 'From'." +_
"Therefor it's not possible to add the sender to your Whitelist.", 16, "Sender not identified"
Else
strdomain = Mid$(strFrom, Instr(strFrom, "@")+1)
If strDomain = strFrom Then
intChoice = 7
Else
intChoice = Messagebox ("Instead of adding the single email address '"+strFrom+"' you may also add the "+_
"whole domain '"+strDomain+"'. This is quite convenient if the domain belongs to a business partner and "+_
"you often receive mails from different users within this domain '"+strDomain+"'."+Chr(10)+Chr(10)+_
"Click 'Yes' to add the domain to your whitelist."+Chr(10)+_
"Click 'No' to add the single email address to your whitelist."+Chr(10)+_
"Click 'Cancel' for no update.", 291, "Update Spam Whitelist")
Select Case intChoice
Case 6
REM Add Domain
strFrom = strDomain
Case 7
REM Add Single Address
Case Else
REM Cancel
Exit Sub
End Select
End If
boolFound = False
Forall strAllowed In item.Values
Select Case True
Case Ucase(strAllowed) = Ucase(strFrom)
boolFound = True
Messagebox "Sender '"+strFrom+"' is already listed in your Whitelist. ", 64, "No need to update Whitelist"
Exit Forall
Case Ucase(strAllowed) = Ucase(strDomain)
boolFound = True
Messagebox "Your Whitelist already contains an entry for Domain '"+strDomain+"'. As the sender '"+_
strFrom+"' also belongs to this domain it is not necessary to add this single emailaddress.", 64, _
"No need to update Whitelist"
Exit Forall
End Select
End Forall
If Not boolFound Then
Call Item.AppendToTextList(strFrom)
If docProfile.Save(False, False) Then
Messagebox "Address '"+strFrom+"' has been added to your Whitelist.", 64, "Whitelist updated"
Else
Messagebox "An error appeared while saving your updated whitelist. Please try again to update your "+_
"whitelist in some minutes. If the problem still appears please contact your Support.", 16, _
"Whitelist could not be updated!"
End If
End If
End If
End If
Set doc = coll.GetNextDocument(doc)
Loop
Print "Agent finished"
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.
The many included activities and demos will make you a pro! Expert instructor help is a click away.
Click here to try a FREE demo course!! |
-- Advertisement --
Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.
Register by April 10 to save $200. |
|
|
|
|
|
|
|
|
|
|