Mail rules enhancement with "wildcard" characteres

I have modified mail rules in the R6.5 template to use wildcard characters → it is more powerfull to fight spams. I have made a minimum of modifications to ensure a compatibility with existant rules. I have just associate with the “is” and “is not” operator the @Matches function (see “Lotus Domino Designer 6.5 Help”) instead of the “=”.

Here are the modifications I made in “Shared Code\Script Libraries\Rules”

Sorry to not mark the lines added or removed in this Sub:

Sub ConditionParser(strcondition As String, strlogic As String, strstring As String)

Dim fieldstring As String

Dim fieldstring2 As String

Dim logicstring As String

Dim bnormal As Integer



bnormal = False



Select Case strcondition

Case "1"

	'//Sender

	Fieldstring = "From : Principal"

Case "2"

	'//Subject

	FieldString = "Subject"

Case "3"

	'//Body

	FieldString = "@Abstract([TextOnly];64994;"""";""Body"")"

Case "4"

	'//Importance

	FieldString = "Importance"

	If Lcase(strstring) = "high" Then

		strstring = "1"

	Elseif Lcase(strstring) = "normal" Then

		strstring = "2"

		bnormal=True

	Elseif Lcase(strstring) = "low" Then

		strstring = "3"

	End If

Case "5"

	'//Delivery Priority

	FieldString = "DeliveryPriority"

	If Lcase(strstring) =  "high" Then

		strstring = "h"

	Elseif Lcase(strstring) = "normal" Then

		strstring = "n"

		bnormal=True

	Elseif Lcase(strstring) = "low" Then

		strstring = "l"

	End If		

Case "6"

	'//To

	FieldString = "SendTo"

Case "7"

	'//CC

	FieldString="CopyTo"

Case "8"

	'//To or CC

	FieldString1 = "SendTo"

	FieldSTring2="CopyTo"

Case "9"

	'//body or subject

	FieldString1 = "@Abstract([TextOnly];64,994;"""";""Body"")"

	FieldSTring2="subject"

Case "A"

	'//BCC

	FieldString=" BlindCopyTo"

Case "B"

	'//Internet Domain

	FieldString = "@If(@IsAvailable(SMTPOriginator);@If(@ValidateInternetAddress([ADDRESS821];SMTPOriginator) = """";@Right(SMTPOriginator;""@"");@False);@False)"

Case "C"

	'//size

	FieldSTring="@DocLength"	

Case "D"

	'// All Documents

	'FieldString = "Select @All"

	FieldString = "@All"

Case "E"

	'// Attachment Names

	FieldString = "@LowerCase(@AttachmentNames)"

Case "F"

	'// Number of Attachments

	FieldString = "@Attachments"

Case "G"

	'// Form

	FieldString = "Form"

Case "H"

	'// Recipient Count

	FieldString = "@Elements(Recipients)"

Case "I"

	'// Any Recipient

	fieldstring = "Recipients"

End Select



Select Case strlogic

Case "1"

	If strcondition = "C" Or strcondition = "F" Or strcondition = "H" Then

		logicstring = "<" 

	Else

		'//contains

		logicstring = "@Contains(@lowercase("			

	End If

	

Case "2"

	'//does not contain

	If strcondition <> "C" And  strcondition <> "F" And strcondition <> "H" Then

		logicstring = "!@Contains(@lowercase("

	Else

		logicstring = ">" 

	End If

Case "3"

	'//is

	logicstring = "@Matches(@LowerCase("

Case "4"

	'//is not

	logicstring = "!@Matches(@LowerCase("

	

End Select



'// Special case for certain types of conditions, such as:

'// Multiple fields, searching Body, when Delivery Priority or Importance are Normal,

'// and Document Size



Select Case strcondition

	

Case "1"

	strformula=strformula+ "(" + logicstring + "@Unique(" + fieldstring+"));"""+ Lcase(strstring) +"""))"

	

Case "C", "H"

	strformula = strformula + fieldstring + logicstring + Ucase(strstring)

	

Case "D"

	strformula = strformula + fieldstring

	

Case "F"

	strformula=strformula + fieldstring + logicstring + strstring

	

Case "4", "5"	'//Importance or Delivery Priority

	'//Values for this case are predefined. Only need to replace value for LogicString

	Select Case strlogic

	Case "1", "3" 	

		If bnormal Then

			logicString = "!@IsAvailable( "		

			strformula=strformula+ logicstring + fieldstring + " ) | "+ fieldstring+" = """ + Lcase(strstring) +""""

		Else

			strformula=strformula + "@LowerCase( " + fieldstring + " ) = """+ Lcase(strstring) +""""				

		End If

	Case "2", "4"

		If bnormal Then

			logicString = "@IsAvailable( "						

			strformula=strformula+ logicstring + fieldstring + " ) & "+ fieldstring+" != """ + Lcase(strstring) +""""

		Else

			strformula=strformula + "@LowerCase( " + fieldstring + " ) != """+ Lcase(strstring) +""""				

		End If			

	End Select

	

Case "8", "9"

	strformula=strformula+ "(" + logicstring + fieldstring1 + ");""" + Lcase(strstring) +""") | "+logicstring+fieldstring2+");"""+ Lcase(strstring) +"""))"

	

Case Else

	strformula=strformula + logicstring + fieldstring + ");""" + Lcase(strstring) + """)"

	

End Select

End Sub

I need to authorize forbidden characteres in rules like *. Set the following lines as comment (I know that it is not the best solution but seems to run fine):

Function ValidateCondition()

		'Msgbox getString(SPEC_STR26), 16, GetString(SPEC_STR28)

		'ValidateCondition = False

End Function

I test this modifications since 2 days and work fine. For example you can easily forbid the words viagra, vi@gra, v.i-agra, v1@gra, etc… with ONE rules → v+?{i1}+?{a@}+?g+?r+?{a@}

If you have any comments or ameliorations don’t hesitate to post here.

Subject: Mail rules enhancement with “wildcard” characteres

Thanks for posting your code.I also made modifications to the rules processing to be able to move mail to a folder based on the form field.

IMO IBM has missed a big opportunity to have a really useful feature by restricting rules so much.

The “quick rules” are fine for users - but at least allow admins the ability to set more complex rules.