convert .eml to .mbox in win32


M

Mike James

Hi, I'm working with some code I copied from here:
http://www.usethesource.com/articles/02/06/17/1957223.shtml

My system: WinXP Home, ActiveState Perl 5.6.1, operated by Perl newbie...

The script is supposed to descend into sub-folders, read *.eml messages,
then concatenate them into .mbox files. The problem is that the script
doesn't descend into the sub-folders. Instead, it only operates on the
files (and folders) in the folder where the script is located.

Here's the script for convert.pl:

sub convert
{
my ($file) = @_;
my $from = '';
my $date = '';
my $message = '';
my $stop_looking = 0;

open OE, "<$file";

while ()
{
my $line;
chomp;
$line = $_;

$message .= $_ . "\n";

if ( $stop_looking == 0 )
{
if ( $line =~ /(From:.*\<(.*)\>)/ )
{
$from = $2;
}
else
{
if ( $line =~ /(From: ([^\<]*))/ )
{
$from = $2;
}
}

if ( $line =~ /Date: (.*)/ )
{
$date = $1;

if ( $date =~ /(\w{3}), (\d+) (\w{3}) (\d{4}) (\d\d:
\d\d:\d\d)/ )
{
my ($dow, $day, $month, $year, $time) = ($1,
$2,$3,$4,$5);

if ( $day =~ /0(\d)/ )
{
$day = " $1";
}

$date = "$dow $month $day $time $year";
}
}

if ( $line =~ /X-UIDL:/ )
{
$message = "\n\nFrom $from $date\n" . $message;

$stop_looking = 1;
}
}
}

close OE;

return $message;
}

sub convert_folder
{
my ($folder) = @_;
my @files = glob "$folder/*.eml";

open MBOX, ">$folder.mbox";
foreach my $file (@files)
{
print "File $file...\n";
print MBOX convert( $file );
}
close MBOX;
}

my @folders = glob '*';
foreach my $folder (@folders)
{
print "Converting $folder...\n";
convert_folder( $folder );
}
 
Ad

Advertisements

J

Jonathan N. Little

shakespeare1 said:
Today, many users are facing troubles about how to convert messages from Windows Live Mail into Thunderbird. Conversion of Live Mail to Thunderbird is not easy task because both supports different email format. Windows Live Mail supports .eml format while Thunderbird supports MBOX format. Without any help of third party tool, Live Mail to Thunderbird conversion is not possible.

In this situation the EML to MBOX Converter is reliable solution to convert your mail messages from Windows 7 mail into Thunderbird, The software also allows you to open or view .eml files into .mbox format with complete emails data like - Mata data (To, Cc, Bcc, Date, Time, From), Attachments & attachment, Content style and Formatting, Image, Hyperlink, Sub-folders & Email folder etc. For more information view below link >> http://www.import-windows-live-mail-to-thunderbird.emltombox.org/
https://sites.google.com/site/emlin...advance-feature/howindows-mail-to-thunderbird


You can just drag and drop EML files directly into Thunderbird no
problem-o. Thunderbird could always import from Outlook and
OutlookExpress with no addons required, not sure about Windows Live
Mail, but if you export as EML Thunderbird has no problem with that
filetype.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top