I know this question has been asked before but I still am not understanding how to acomplish this task. I have downloaded the message using Mail::POP3Client. The email comes with text in the body as well as three attachments. The single attachment I want will always be named the same way so it seems this should not be hard to acomplish. I have looked at code to use MIME::Parser and also Email::MIME::Attachment::Stripper but I haven't gotten either of these to work. What method do you suggest using and could you give an example? Here is the code I was attempting to use to get the attachment using Email::MIME::Attachment::Stripper
#!/usr/bin/perl use Mail::POP3Client; use Email::MIME; use Tie::File; use Email::MIME::Attachment::Stripper; my $pop_user = "user@server.com"; my $pop_pass = "password"; my $pop_server = "pop.server.com"; $pop = new Mail::POP3Client( USER => $pop_user, PASSWORD => $pop_pass, HOST => $pop_server, AUTH_MODE => 'PASS'); $message = $pop->Body(1); my $parser = Email::MIME->new($message); my @parts = $parser->parts; print @parts[1]; $stripper = Email::MIME::Attachment::Stripper->new(@parts[1]); my @attachments = $stripper->attachments; print @attachments[0]; $pop->Close();

In reply to Extracting Attachment from Email by ProgramIT

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.