Please feel free to provide input and suggestions.
{ This script can be run on incoming or selected messages
{ and will read from a user-specified input "match" file.
{ If any of the lines in the input file are found to be
{ present in either the Subject or From field of the email
{ message, the message will then be moved to a user-specified
{ mailbox. Both the user-specified "match" file name and
{ the mailbox name can be changed in the Script Setup.
{ The match-file must be located in the main Poco
{ applicaiton directory.
{
{ This provides functionality similar to the %file% comparison
{ operation provided by PocoMail, but matches only one way --
{ i.e., the entire match line in the input file must be
{ present in the subject or the from fields for a match to be
{ found.
{
{ I use this script to sort all of my newsletters into a
{ Poco mailbox called "To Read".
{
{ You can have multiple versions of this script, with each
{ one's setup referencing a different match input file and
{ target mailbox. In this case, just copy and rename the
{ script in the Poco Script directory and change the Setup
{ Parameters accordingly for each different match/move.
{ The mailbox specified in the script setup must exist.
{ The input / match file should be saved in the /mail directory.
{
{ Written 08-12-04 by Sean Curley
{
External $userdata1 "Match Text File Name" #file.txt
Set $ifilename $userdata1
External $userdata2 "Mailbox to Move Matches Into" mailbox
Set $mailbox $userdata2
{ Verify that the specified Poco Mailbox exists
Set $mailboxfile $mailpath
AddStrings $mailboxfile $mailbox
AddStrings $mailboxfile ".mbx"
FileExists &mailboxexists $mailboxfile
{ Verify that the specified Match input file exists
Set $mfilename $mailpath
AddStrings $mfilename $ifilename
FileExists &mfileexists $mfilename
{ If either mailbox or file are missing go to error routine
Set &Error1 &mailboxexists
Set &Error2 &mfileexists
Not &Error1
Not &Error2
Or &Error1 &Error2
If &Error1 then FileError
{ Get Subject and From fields; convert to lowercase
ReadHeader $subject "Subject:" %message
Lowercase $subject
ReadHeader $from "From:" %message
Lowercase $from
{ Read input match file, convert to lowercase, trim,
{ and check that not empty
Set $OnErrorGoTo "FileError"
OpenBody $matchfile $mfilename
LowerCase $matchfile
TrimLines $matchfile
LineCount #linecount $matchfile
If #linecount < 1 then FileError
Set #loopcount 1
:FileLoop
Set #linepos #loopcount
SubIntegers #linepos 1
{ Read input line, convert to lowercase
GetLine $currentline #linepos $matchfile
Lowercase $currentline
{ If match found, go to Match move routine
If $currentline ^ $subject then Match
If $currentline ^ $from then Match
If #loopcount = #linecount then End
Inc #loopcount
Goto FileLoop
{ Match routine savies msg to specified mailbox,
{ checks if successful, { and then deletes from
{ initial mailbox
:Match
Set $OnErrorGoTo "MoveFailed"
SaveMessage %message $mailbox
DeleteMessage %message
Goto End
:FileError
MessageBox "Empty or Missing Match File and/or Mailbox"
Goto End
:MoveFailed
MessageBox "Could Not Move Message"
:End
Exit