Hi all,

I am trying to take a MIME email on STDIN and then extract any attatchment and re-assemble them into a fresh message (after I've performed a few tasks on the original irrelevant to this question)

Here is my code that takes a Mail::Internet message and parses it into parts using MIME::Parser. I can get the mime types no probs using $parts[$i]->mime_type but which method do I call to get the file name and data for each part. There seems to be little info in the docs.
use Mail::Internet; use MIME::Parser; $mail = new Mail::Internet \*STDIN; # Create new parser my $parser = new MIME::Parser; # Keep parsed message bodies in core $parser->output_to_core('ALL'); # Make the Mail::Internet message into an array @lines = (@{$mail->header}, "\n", @{$mail->body}); # Parse an in-core MIME message $parser->parse_data(\@lines); $ent->make_multipart; @parts = $ent->parts; foreach my $i ( 0 .. $#parts ) { print "Part $i ". $parts[$i]->mime_type . "\n\n"; }
(In the real app the print bit in the above loop would probably be used to add parts to MIME::Lite message or similar!)

Many thanks

Stew

In reply to Carving up MIME email on STDIN by stew

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.