Sample code for 30+ languages & platforms
DataFlex

Get the Total Size of a POP3 Mailbox

See more POP3 Examples

Demonstrates the Chilkat MailMan.GetMailboxSize method, which returns the total combined size, in bytes, of all messages currently stored in the POP3 mailbox — also known as the POP3 maildrop size. This example configures the POP3 connection and reads the total size.

Background: POP3 reports the maildrop size via its STAT command, which returns both a message count and the aggregate byte size. Knowing the total up front is useful for estimating download time and bandwidth, or for deciding whether to fetch everything at once versus one message at a time — especially over slow links or when the mailbox is large.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoMailman
    Integer iTemp1

    //  Demonstrates the MailMan.GetMailboxSize method, which returns the total combined size, in
    //  bytes, of all messages currently stored in the POP3 mailbox (the POP3 maildrop size).

    Get Create (RefClass(cComChilkatMailMan)) To hoMailman
    If (Not(IsComObjectCreated(hoMailman))) Begin
        Send CreateComObject of hoMailman
    End

    //  Configure the POP3 server connection.
    Set ComMailHost Of hoMailman To "pop.example.com"
    Set ComMailPort Of hoMailman To 995
    Set ComPopSsl Of hoMailman To True
    Set ComPopUsername Of hoMailman To "user@example.com"
    Set ComPopPassword Of hoMailman To "myPassword"

    Get ComGetMailboxSize Of hoMailman To iTemp1
    Showln "Total mailbox size (bytes): " iTemp1

    //  Note: Explicitly connecting/authenticating is optional.  Chilkat MailMan automatically
    //  connects and authenticates -- using the property settings above -- whenever a server
    //  operation requires it.  Calling the explicit connect/authenticate methods can still be
    //  helpful to determine whether a failure occurs while connecting or while authenticating.


End_Procedure