Re: MIME::Parser .. how to get just the message part of the body
- From: ivan.delchev@xxxxxxxxx
- Date: 16 Sep 2005 12:45:25 -0700
try this one.Incomming poarameter must be text of the message
sub get_email_body {
my $MESSAGE = shift;
use MIME::Parser;
$parser = MIME::Parser->new( );
$message = $parser->parse_data($MESSAGE); # die( )s if can't parse
$head = $message->head( ); # object--see docs
$preamble = $message->preamble; # ref to array of lines
$epilogue = $message->epilogue; # ref to array of lines
print "\npreamble:".Dumper($preamble);
print "\nepilogue:".Dumper($epilogue);
$num_parts = $message->parts;
for (my $i=0; $i < $num_parts; $i++) {
my $part = $message->parts($i);
my $content_type = $part->mime_type;
my $body = $part->as_string;
# print "\n".$content_type."\n";
# print "\n".$body."\n\n\n";
if ($content_type eq 'text/plain') {
return $part->bodyhandle->as_lines;
}
}
}
.
- References:
- MIME::Parser .. how to get just the message part of the body
- From: matthewlenz
- MIME::Parser .. how to get just the message part of the body
- Prev by Date: Re: Simple question
- Next by Date: Math-Random-MT-Auto-4.08.00.tar.gz
- Previous by thread: Re: MIME::Parser .. how to get just the message part of the body
- Next by thread: Errors installing XML::Parser from CPAN on Solaris 9
- Index(es):