I've got a simple script to download emails w/ attachments from Gmail. What is happening is that the message count is set to zero after I do a read. That's fine & what I would expect. But I'd like to know if there's some way to avoid clearing the message count, so I could download messages again if needed. $pop->reset() doesn't make a difference... ========================
$pop = new Mail::POP3Client( USER => $USER, PASSWORD => $PW, HOST => $SERVER, USESSL => 'true', # DEBUG => 1, PORT => 995 ); print "Status: ". $pop->State()." unread emails:". $pop->Count()."\n"; $count=$pop->Count(); #<<<set to zero after download if($count < 0 ){ print "Error: Gmail returned ".$pop->Message()."\n"; exit; } elsif ($count == 0){ print "No messages for $USER\n"; exit; } for( $i = 1; $i <= $count; $i++ ) { foreach( $pop->Head( $i ) ) { /^(From|Subject):\s+/i && print $_, "\n"; } $body=$pop->HeadAndBody($i); $stripper=Email::MIME::Attachment::Stripper->new($body); $msg=$stripper->message; @attachments=$stripper->attachments; foreach $attachment (@attachments){ # print "$#attachments found\n"; # add code to save attachments here # structure # $attachments[$i] # 0 HASH # 'content_type' => 'text/xml' # 'filename' => 'foo.xml' # 'payload' => "<attachment> # } } $pop->Reset(); $pop->Close();

In reply to Gmail message count reset by pdxperl

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.