MIME::Parser .. how to get just the message part of the body

M

matthewlenz

#!/usr/bin/perl

use MIME::parser;
use Data::Dumper qw(Dumper);

$parser = MIME::parser->new( );
$parser->output_to_core(1); # don't write attachments to disk

while (<STDIN>) {
$MESSAGE .= $_;

}

$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

$num_parts = $message->parts;
for (my $i=0; $i < $num_parts; $i++) {
print "part number = $i\n";
my $part = $message->parts(1);
my $content_type = $part->mime_type;
my $body = $part->as_string;
print $body;

}

.......................

When I print the body I get the content headers as well. Is there a
way to just get the actual content?

-Matt
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top