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

[MacPerl] Script to convert mail from Claris Emailer to Eudora



Usually I post to this list (occasionally) to ask for something,
but this time I want to contribute a script I developed to allow
me to migrate CLARIS EMAILER (version 1.1) mail folders to Eudora.

I tried out Emailer early this year, but moved to Eudora 3.0 Lite
for the main reason that Emailer was saving messages as individual
files in a folder. It wasnt possible to have nested folders, and
filtered messages couldnt be displayed as read or unread. (The
product comparison is not the subject of this message..I digress)

This script firstly prompts for the name of the file to create
which will be a single file version in Eudora format.
You will then be prompted for the folder name of messages to
join together.

Emailer creates file names based on the Subject line, so the file
names were long and often contained parentheses, commas, spaces.
MacPerl had problems opening these file names (it appeared to be
processing the names as regular expressions!), so I filtered
out bad characters from the name, renamed the file and tried again.

Once you have created the mailbox files, you will have to put them
in the Eudora folder (the one that contains In, Out and Trash) and
restart Eudora.  This method probably works for Netscape mail as well.

Here we go.....

Charles

# join_emailer.pl
#
# Author: Charles Cave     3rd Dec 1996
#
# Joins all the files found in a directory of Claris Emailer into
# one big mail box file suitable for Eudora
#
# Each file in a Claris Email Filing Cabinet has header lines in
# the following order:  (definitely NOT a standard format!)
#
# Subject:
# Sent:
# Received:
# From:
# To:

require "ctime.pl";
require "StandardFile.pl";
$firstmsg = "y";

$outfilename = &StandardFile::PutFile('Output file', "MailboxFile");

open(RESULT, ">".$outfilename) || die "cant create file $filechoice\n";
$tf = 0;

$respdir = &StandardFile::GetFolder("Choose Filing Cabinet Directory", "");
chdir($respdir) || die "chdir failed\n";

@shortmon = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
   "Aug", "Sep", "Oct", "Nov", "Dec");

$col = ":";

foreach $file (<*>) {
  print "$file\n";
  $oldfile = $file;
  $inheader = 1;
  $file =~ s/\(//g;   # otherwise the open will fail
  $file =~ s/\)//g;
  $file =~ s/\<//g;
  $file =~ s/\>//g;
  $file =~ s/\,//g;
  $file =~ s/ //g;
  rename $oldfile, $file;

  open(INFILE,$file) || die "couldnt open $file\n";

  while(<INFILE>) {
    chop;

    if ($inheader == 1) {  # flag to determine if we are in header or body
       if (length($_) < 2) {
          $inheader = 0;
          if ($firstmsg eq "y")  {
             $firstmsg = "";
          } else { print RESULT "\n"; }
# dates look like dd/mm/yy hh:mm AM  (in Claris Emailer)
# but should be Dayname MonthName dd hh:mm:ss YYYY   (for Eudora)
          ($dmy, $hm, $ampm) = split(/ /,$dateline);
          ($d,$m,$y) = split(/\//,$dmy);
          ($hour,$min) = split(/:/,$hm);
          if ($ampm eq "PM") { $hour = $hour + 12; }
          $fullmonth = @shortmon[$m-1];
# output first line of mail header
          print RESULT "From ???@??? ";
          print RESULT "Mon $fullmonth $d $hour$col$min$col15 19$y\n";
# Output the From Line
          if ($fromline ne "") {
               print RESULT "$fromline\n";
          } else {
# change following line to use YOUR email address
             print RESULT "From: Charles Cave <charles\@jolt.mpx.com.au>\n";
          }
# Output the subject line
          if ($subjline eq "") {
             print RESULT "Subject: Unknown subject\n";
          } else {
              print RESULT "$subjline\n";
          }
          print RESULT "Date: $d $fullmonth 19$y $hour$col$min$col";
          print RESULT "15 +1000\n";
          if ($recdline ne "") { print RESULT "$recdline\n"; }
          if ($toline ne "") { print RESULT "$toline\n"; }
          print RESULT "\n";     # Blank line between header and body
       } else {
          s/\s+/ /g;
          if (/^Subject:/) {
           $subjline = $_;
         } elsif (/^Sent/) {
            $dateline = $_;
            $dateline =~ s/Sent: //;
         } elsif (/^Received/) {
            $dateline = $_;
            $dateline =~ s/Received: //;
         } elsif (/^From/) {
            $fromline = $_;
         } elsif (/^To/) {
            $toline = $_;
         } else {
#           print "Unknown header line $_\n";
       }
       }
     } else {
       print RESULT "$_\n";
    }
  }  # end while INFILE loop
  close(INFILE);
  $tf += 1;
  print "$tf file completed\n";

} # end foreach $file loop
print "\n\n$tf files processed\n";

close(RESULT);


-----------------------------------------------------------------
      Charles Cave                         Sydney, Australia
      Email:                         charles@jolt.mpx.com.au
-------------http://www.ozemail.com.au/~caveman/------------------



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch