in reply to Using MIME::Tools
UPDATED, the following code works betterif ($MIME_entity->parts > 0) { for (my $i=0;$i<$MIME_entity->parts;$i++) { my $subEntity = $MIME_entity->parts($i); if (($types->{$subEntity->mime_type} eq 'text/html') || ($types->{$subEntity->mime_type} eq 'text/plain')) { if (my $io = $entity->open("r")) { while (defined($_=$io->getline)) {$recHash->{body} = $recHash->{body} . $_;} $io->close; } } } }
#!/usr/bin/perl use MIME::Parser; use Data::Dumper; $parser = new MIME::Parser; $parser->ignore_errors(1); $parser->output_to_core(1); my $MIME_entity = $parser->parse(\*STDIN); my $error = ($@ || $parser->last_error); if ($MIME_entity->parts > 0) # Is this a multipart { print ">> Multi Part Message\n"; for (my $i=0;$i<$MIME_entity->parts;$i++) { my $subEntity = $MIME_entity->parts($i); print ">> MIME: ", $subEntity->mime_type," \n"; if (($subEntity->mime_type eq 'text/html') || ($subEntity->mime_type eq 'text/plain')) { if (my $io = $subEntity->open("r")) { while (defined($_=$io->getline)) {print $_} $io->close; } } } } else { my $body = join "", @{$MIME_entity->body}; print ">> Not a multipart\n"; print $body; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using MIME::Tools
by Anonymous Monk on Nov 24, 2001 at 02:24 UTC | |
by atlantageek (Monk) on Nov 24, 2001 at 02:40 UTC | |
by Anonymous Monk on Nov 24, 2001 at 02:51 UTC |