in reply to Re^2: parsing text portion out of email
in thread parsing text portion out of email

NAAHH...
Too fast there....
Hangs on this code... gotta figure out why?

#!/usr/bin/perl -w use strict; use Email::Simple; my $dir = "."; opendir (DH, $dir) or die "Can't open directory $dir: $!"; while (defined (my $file = readdir(DH))) { next if ($file =~ /^\.\.?$/); open (FH, "$dir\\$file") or die "Can't open $dir\\$file: $!\n"; my $e = do { local $/; <FH> }; # slurp .msg file my $mail = Email::Simple->new($e); # convert to mail object (?) $e = $mail->body; # retrieve body text print $e; # dump to STDOUT close(FH) or die "Can't close $dir\\$file: $!\n"; } closedir(DH) or die "Can't close $dir: $!";

allan

Replies are listed 'Best First'.
Re^4: parsing text portion out of email
by gellyfish (Monsignor) on Mar 31, 2005 at 14:46 UTC

    I would recommend using Email::Folder (Or one of its relatives) to access the collection of e-mails rather than doing it yourself like that:

    use Email::Folder; my $dir = "."; my $folder = Email::Folder->new($dir); foreach my $message ( @{$folder->messages()}) { print $message->body(); }
    (Untested as I don't have a maildir delivery)

    /J\