Re: MIME::Parser .. how to get just the message part of the body
- From: Gerard Lanois <gerardlanois@xxxxxxxxx>
- Date: Sat, 10 Sep 2005 03:45:09 GMT
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
.
- 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: Request for naming help (templating module)
- Next by Date: Re: Request for naming help (templating module)
- Previous by thread: MIME::Parser .. how to get just the message part of the body
- Next by thread: Re: MIME::Parser .. how to get just the message part of the body
- Index(es):