Sample code for 30+ languages & platforms
Unicode C

Compare Two Emails by UIDL

See more Email Object Examples

Demonstrates the Chilkat Email.UidlEquals method, which returns true if this email's UIDL equals the UIDL of the email passed as the argument. The comparison is meaningful for messages obtained through POP3. This example gives two emails the same UIDL and compares them.

Background: A POP3 UIDL is a stable, unique identifier a server assigns to each message in a mailbox. Comparing UIDLs is how a client decides whether two message references point to the same server message — the basis for "leave messages on server" logic, where an app downloads a message once and skips it on later checks by remembering its UIDL.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkEmailW.h>

void ChilkatSample(void)
    {
    HCkEmailW email1;
    HCkEmailW email2;
    BOOL eq;

    //  Demonstrates the UidlEquals method, which returns true if this email's UIDL equals the
    //  UIDL of the email passed as the argument.  UIDLs are POP3 message identifiers.

    email1 = CkEmailW_Create();
    CkEmailW_AddHeaderField(email1,L"X-UIDL",L"0000000123abcdef");

    email2 = CkEmailW_Create();
    CkEmailW_AddHeaderField(email2,L"X-UIDL",L"0000000123abcdef");

    //  Compare the two emails' UIDLs.
    eq = CkEmailW_UidlEquals(email1,email2);

    if (eq == TRUE) {
        wprintf(L"The two emails have the same UIDL.\n");
    }
    else {
        wprintf(L"The two emails have different UIDLs.\n");
    }



    CkEmailW_Dispose(email1);
    CkEmailW_Dispose(email2);

    }