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



matthewlenz@xxxxxxxxx writes:

> #!/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);
^
^
^

Possible source of trouble here. Maybe you meant $i???

-Gerard


> 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
.