[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] A MacPerl program to filter Eudora IN box



Many of the postings on the Mac_Perl list relate to running
web servers.

My usage of MacPerl is for massaging files and directories on my
machine, and I have just completed a program to filter the
"In" folder of Eudora 1.5.5 into various folders.

Yes I know I could buy Eudora PRO which has filtering but it
co$t$ money! And Claris Emailer has some shortcomings, and
Netscape 3.0 doesn't have filters.

Applescript may be able to do it, but I couldn't find a
"transfer message" in the dictionary of Eudora.


The script has to be configured with path names and rules, and
once you have run the program, you need to do the following:

a) Manually clear out the "In" folder"
b) When you open each mail folder, you will be told that the
   table of contents is wrong and asked to rebuild it. So far,
   rebuilding works fine.

I hope this script is useful and educational...



# filter the "In" folder of my Eudora Mail box

# following is path name for a temporary file
$tmpfile = "MacintoshHD:Internet:eudoratmp";

# define your rules here...
%filterrules = (
   "perl" => "MacintoshHD:System Folder:Eudora Folder:MacPerl",
   "mahler" => "MacintoshHD:System Folder:Eudora Folder:Music:Mahler",
   "unfiltered" => "MacintoshHD:System Folder:Eudora Folder:Unfiltered",
   "jjoyce" => "MacintoshHD:System Folder:Eudora Folder:Joycean:J-Joyce",
   "fwake" => "MacintoshHD:System Folder:Eudora Folder:Joycean:FWAKE",
   "buzan" => "MacintoshHD:System Folder:Eudora Folder:Creativity:BUZAN",
   "debono" => "MacintoshHD:System Folder:Eudora Folder:Creativity:DEBONO",
   "jokes" => "MacintoshHD:System Folder:Eudora Folder:Jokes"
);

# check the file name here...
open (IN,"MacintoshHD:System Folder:Eudora Folder:In")
     || die "could not open In folder\n";

$firstmsg = "Y";

while(<IN>)  {
  chop;
  if (/^From \?\?/) {
     $thisline = $_;
     if ($firstmsg eq "N") {
        &processtmpfile;
     } else {
        $firstmsg = "N";
     }
     $targetfolder = "unfiltered";
     open(TMP,">".$tmpfile) || die "could not open $tmpfile for writing\n";
     print TMP "$thisline\n";
   } else {
# derive the target by examining mail headers. Rule definitions start here
    if (/^sender:/i) {
       if (/mac\-perl/) {
          $targetfolder = "perl";
       }
       if (/DEBONO/) {
          $targetfolder = "debono";
       }
       if (/BUZAN/) {
          $targetfolder = "buzan";
       }
    }
    if (/^To:/) {
       if (/MAHLER/) {
          $targetfolder = "mahler";
       }
       if (/FWAKE/) {
         $targetfolder = "fwake";
       }
       if (/j\-joyce/) {
          $targetfolder = "jjoyce";
       }
    }
    if (/^From:/) {
       if (/Chazan/) {
          $targetfolder = "jokes";
       }
    }
# end of filter definitions.
    print TMP "$_\n";
   }
}
&processtmpfile;


sub processtmpfile {
  close(TMP);
  open(TMP,$tmpfile) || die "could not open $tmpfile for reading\n";
  $mailbox = $filterrules{$targetfolder};
  print "*** Transferring $targetfolder ==> $mailbox\n";
  open (OUT,">>".$mailbox) || die "could not open $mailbox\n";
  while (<TMP>) {
     chop;
     if (/^Subject/) { print "   $_\n"; }
     if (/^From:/) { print "   $_\n"; }
     print OUT "$_\n";
  }
  close(TMP);
  close(OUT);
}



------------------------------------------------------
Charles Cave                         Sydney, Australia
Email:                         charles@jolt.mpx.com.au
------------------------------------------------------