IMAP – Search for Messages by Message-ID or any Email Header Field

Using the Chilkat IMAP API: To download emails having the exact contents of a header field, or all emails where a given header field contains a specified substring, use the Search method like this:

    (C++)
    CkMessageSet *mset = imap.Search("HEADER Message-ID 48208D0C",true);

    (C#)
    Chilkat.MessageSet mset = imap.Search("HEADER Message-ID 48208D0C",true);

If the Search method returns a non-NULL message set object, then download the emails by calling FetchBundle:

    (C++)
    CkEmailBundle *bundle = imap.FetchBundle(mset);

    (C#)
    Chilkat.EmailBundle bundle = imap.FetchBundle(mset);

Once you have an email bundle object, you may iterate over the emails contained within the bundle.
See the IMAP examples at http://www.example-code.com/
(There are examples in many different programming languages)

Tags :