Re: Count messages in a Imap-Mailfolder
[email protected] ("John W. Krahn")
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <[email protected]> |
Michelle Konzack wrote:
> ************************************************************************
> * Do not Cc: me, because I READ THIS LIST, if I write here *
> * Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe *
> ************************************************************************
>
> Hello,
Hello,
> since I live in a region where I have NO telephone line which mean no
> Internet too I am connecting to the internet over GSM/GPRS. But there is
> a big problem: I have several mail accounts and I am on MANY mailing-
> lists...
>
> Now, before downloading the messages I like to check from a small script
> how many messages are in the Mailaccount and the size. OK, the number
> of mesages is no problem but the total size.
>
> Querying an account with 3500 messages daily cost 1700 kByte GSM/GPRS
> traffic which is realy expensive.
>
> Now since I am beginner in perl, I like to know, whether there is a
> function to get the total size of a IMAP folder?
>
> Note: I use the Debian package "libnet-imap-simple-perl"
> if it is important for you to help.
According to the documentation for that module:
list
my $message_size = $imap->list($message_number);
my $mailbox_sizes = $imap->list;
This method returns size information for a message, as indicated
in the single optional parameter, or all messages in a mailbox.
When querying a single message a scalar value is returned. When
listing the entire mailbox a hash is returned. On failure,
"undef" is returned.
So if you use list() with no message number supplied it will return a
*reference* to a hash that contains the message numbers as the keys and
the corresponding message sizes as the values.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall