[pmmail-list] Filter statistics
Steve Barber
pmmail-list@blueprintsoftwareworks.com
Sun, 07 Mar 2004 01:01:40 -0500
On Sat, 06 Mar 2004 20:30:32 -0600, Jon Etkins wrote:
>or if
>anyone has done anything more fancy that they would care to throw out
>here to be plagiarised. :)
>
>Thanks,
> Jon Etkins
I hadn't done it before, but for fun I threw this together
in VBS in about 30 min ... no guarantees .... of course, it
will only works in Windows ... maybe it will give you some
ideas, anyway.
I'm sure this could be done easier ... and certainly easier
in REXX, but I think this approach would work in Windows
using VisualBasicScript.
Here's what you 'd have to do to try it.
1) Copy/Paste the code below into a text file with a .vbs
extension.
2) Save it wherever you want.
3) Put a file called CountFile.txt in c:/temp/ with just
the number 0 in it as a text character.
4) Call it from a hook on every email read.
5) Authorize it when it first runs (you can look at it and
see it's not very malicious).
The script opens the text file passed to it by PMMail for
reading, reads in the previous counters, then closes the
file, and reopens it for writing. It adds 1 to the
appropriate counter (your problem to figure this part out)
and writes the new count back in the CountFile.txt file
replacing the old counts with the new ones.
Of course, you can change the files and paths to be
anything you want.
'Call this program from your pmmail hook for incoming mail
'pass a pointer in arg to the incoming file to this program
dim arg
arg = WScript.Arguments(0)
'declare that you want to use the FileSystemObject
Set objFSO =
CreateObject("Scripting.FileSystemObject")
arg = "C:\Program Files\SouthSoft\PMMail 98\" + arg
'change to your mail path
'Open the incoming mail file for reading
Set objInFile = objFSO.OpenTextFile(arg, 1)
'read the mail file with ReadLine and figure out which
bucket to count this
'add your code here to do that
'add as many count type variables as you have types
you want to count (if only put one here)
dim mailtype ' set this to the type you determine
... "spam" "valid" or whatever
dim count
'Open the Counter Text file you created; read the
counter(s) and update them
Set objCountFile =
objFSO.OpenTextFile("C:\temp\CountFile.txt", 1)
count = objCountFile.ReadLine
if mailtype = "spam" then
count = count + 1 ' in the spam counter
end if
'add other if statements and their counter
variables here.
objCountFile.Close
Set objCountFile = Nothing
'Open the Counter Text file again for writing and write all
the new counter values using WriteLine
Set objCountFile =
objFSO.OpenTextFile("C:\temp\CountFile.txt",
ForWriting,True)
objCountFile.WriteLine(count)
'do the above statement for each type of mail you
are counting
objCountFile.Close
Good luck, SteveB
- pmmail-list - The PMMail Discussion List ---------------------------
To POST to the list, send your message to:
pmmail-list@blueprintsoftwareworks.com
To UNSUBSCRIBE, send a message to mdaemon@bmtmicro.com
with the first line of the message body being...
UNSUBSCRIBE pmmail-list@blueprintsoftwareworks.com
---------------------------------------------------------------------