boosth has asked for the wisdom of the Perl Monks concerning the following question:
Sometimes this works: A)$parser = MIME::Parser->new( ); $parser->ignore_errors(1); $parser->extract_uuencode(1); $parser->extract_nested_messages(1); $parser->output_to_core(1); # don't write attachments to disk my $tmpMessage = $parser->parse_data($body); my $tmp_num_parts = $tmpMessage->parts; for (my $ii=0; $ii < $tmp_num_parts; $ii++) { my $tmp_part = $tmpMessage->parts($i); my $tmp_content_type = $tmp_part->mime +_type; my $tmp_body = $tmp_part->as_string;
and sometimes this works: B)if ($tmp_body =~ /Content-Transfer-Encoding: base64/i) { $MessageBody = " ". $ +tmp_part->bodyhandle->as_string; }
What I am finding difficult to figure out is how do I handle both cases gracefully. Afaict it is one or the other without some hideous method to check if the text is somehow readable for a human.if ($tmp_body =~ /Content-Transfer-Encoding: base64/i) { $MessageBody = " ". d +ecode('UTF-8',decode_base64($tmp_part->bodyhandle->as_string)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MIME::Parser parse_data
by Corion (Patriarch) on Jan 17, 2013 at 17:20 UTC | |
by boosth (Initiate) on Jan 17, 2013 at 18:19 UTC | |
by Corion (Patriarch) on Jan 17, 2013 at 18:25 UTC | |
by boosth (Initiate) on Jan 17, 2013 at 18:57 UTC | |
by Corion (Patriarch) on Jan 17, 2013 at 19:08 UTC | |
by boosth (Initiate) on Jan 17, 2013 at 20:42 UTC | |
by boosth (Initiate) on Jan 17, 2013 at 23:15 UTC |