Tighe
Well-known member
Importing Private Messages into Mozilla Thunderbird
My private messages fill up all the time and this is Very useful! Just download all your messages as TXT from the private messages page using the link near the bottom of the page, or just use this link:
http://forums.arcade-museum.com/private.php?do=downloadpm&dowhat=txt
Then convert the txt file using the perl code I found here:
http://www.southbayriders.com/forums/showthread.php?t=74172&page=1
And then to import:
http://support.mozillamessaging.com...ox+import&as=s#w_importing-evolution-messages
End results!
My private messages fill up all the time and this is Very useful! Just download all your messages as TXT from the private messages page using the link near the bottom of the page, or just use this link:
http://forums.arcade-museum.com/private.php?do=downloadpm&dowhat=txt
Then convert the txt file using the perl code I found here:
http://www.southbayriders.com/forums/showthread.php?t=74172&page=1
Code:
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use open IN => ':crlf';
sub usage {
print STDERR "Usage: txt2mbox sbr-messages.txt\n";
print STDERR " Writes one output file per SBR folder.\n";
exit 1;
}
&usage if ($#ARGV != 0);
my $infile = shift;
open(INFILE, "<:crlf", $infile) ||
die "Could not open $infile: $!";
my $folder = '';
my $folder_boundary = '#' x 80;
my $header_boundary = '=' x 80;
my $message_boundary = '-' x 80;
my $pushback = '';
my $msgno = 0;
while (1) {
if ($pushback) {
$_ = $pushback;
$pushback = '';
} elsif ($_ = <INFILE>) {
chomp;
} else {
last;
}
if (/^${folder_boundary}$/) {
# Close current output file, if any
if ($folder) {
close FOLDER;
$folder = '';
}
# Switch output file to new folder name
$_ = <INFILE>; chomp; # Get line with folder name
die "Expected folder name"
if !/^Folder :\t(.*)$/;
$folder = $1;
print "Writing folder $folder\n";
$_ = <INFILE>; chomp; # Skip folder end boundary
$_ = <INFILE>; chomp; # Skip blank line
open(FOLDER, ">$folder") ||
die "Could not open output file $folder: $!";
} elsif (/^${header_boundary}$/) {
die "Message not in folder" if (!$folder);
# Read header lines From, To, Date, Title
$_ = <INFILE>; chomp;
die "Missing From"
if !/^From :\t(.*)$/;
my $hdr_from = $1;
$_ = <INFILE>; chomp;
die "Missing To"
if !/^To :\t(.*)$/;
my $hdr_to = $1;
$_ = <INFILE>; chomp;
die "Missing Date"
if !/^Date :\t(.*)$/;
my $hdr_date = $1;
$_ = <INFILE>; chomp;
die "Missing Title"
if !/^Title :\t(.*)$/;
my $hdr_title = $1;
# Parse the date
die "Invalid date format"
if ($hdr_date !~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)$/);
my $unix_time = mktime(0, $5, $4, $3, $2 - 1, $1 - 1900);
my $t1str = strftime("%a %b %d %H:%M:%S %Y",
localtime($unix_time));
my $t2str = strftime("%a, %d %b %Y %H:%M:%S %z (%Z)",
localtime($unix_time));
printf "Writing message %d\n", ++$msgno;
print FOLDER "From user\@KLOV.com $t1str\n";
print FOLDER "Date: $t2str\n";
print FOLDER "From: \"$hdr_from\" <user\@KLOV.com>\n";
print FOLDER "To: \"$hdr_to\" <user\@KLOV.com>\n";
print FOLDER "Subject: $hdr_title\n";
print FOLDER "\n";
} elsif (/^${message_boundary}$/) {
die "Message not in folder" if (!$folder);
while (<INFILE>) {
chomp;
if (/^(${header_boundary}|${folder_boundary})$/) {
$pushback = $_;
last;
}
if ($_ =~ /^From /) {
print FOLDER ">$_\n";
} else {
print FOLDER "$_\n";
}
}
} elsif ($folder) { # Skips junk at beginning of file
die "Expected folder or message";
}
}
if ($folder) {
close FOLDER;
$folder = '';
}
close INFILE;
And then to import:
http://support.mozillamessaging.com...ox+import&as=s#w_importing-evolution-messages
Copy all the file without extension (such as Inbox, Outbox,..) into the emplacement used by Thunderbird to store its mail (something like ~/.thunderbird/uk41lql0.default/Mail/Local Folders,where you need to adapt uk41lql0.default to your own installation).
Launch Thunderbird to check that all your mail have been correctly imported.
End results!

