Sample code for 30+ languages & platforms
Unicode C

Get the POP3 Mailbox Message Count

See more POP3 Examples

Demonstrates the Chilkat MailMan.GetMailboxCount method, which returns the number of emails currently available in the POP3 mailbox, or -1 if an error occurs. It is functionally identical to CheckMail. This example configures the POP3 connection and reads the count.

Background: The message count is the number of messages sitting in the POP3 maildrop — the server-side spool that holds mail until a client downloads (and typically deletes) it. Because POP3's traditional model moves mail off the server, this count is essentially the size of the "inbox to be picked up." Chilkat auto-connects using the configured MailHost, credentials, and SSL settings if no session is open.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkMailManW.h>

void ChilkatSample(void)
    {
    HCkMailManW mailman;
    int count;

    //  Demonstrates the MailMan.GetMailboxCount method, which returns the number of emails
    //  currently available in the POP3 mailbox (or -1 if an error occurs).  It is functionally
    //  identical to CheckMail.

    mailman = CkMailManW_Create();

    //  Configure the POP3 server connection.
    CkMailManW_putMailHost(mailman,L"pop.example.com");
    CkMailManW_putMailPort(mailman,995);
    CkMailManW_putPopSsl(mailman,TRUE);
    CkMailManW_putPopUsername(mailman,L"user@example.com");
    CkMailManW_putPopPassword(mailman,L"myPassword");

    count = CkMailManW_GetMailboxCount(mailman);
    wprintf(L"Mailbox message count: %d\n",count);

    //  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.


    CkMailManW_Dispose(mailman);

    }