Quantcast
Channel: Rebex Q&A Forum - Recent questions and answers
Viewing all articles
Browse latest Browse all 3862

Answered: Searching IMAP and EWS for emails that are NOT UID

$
0
0

Hello,

unfortunatelly neither EWS, or IMAP protocol have support for directly searching for messages according to their UniqueID/EWS ID.

So you have to search for all the messages that arrived at the specific date (or according to other criteria). This will give you a list from which you have to filter out yourself the messages that already have been processed.

Something like this:

Dictionary<string, bool> processedUIDs = new Dictionary<string, bool>();

// search for messages that arrived today
ImapMessageCollection list = imap.Search(ImapSearchParameter.Arrived(DateTime.Now));
ImapMessageCollection filtered = new ImapMessageCollection();

foreach (var messageInfo in list)
{
    if (!processedUIDs.ContainsKey(messageInfo.UniqueId))
        filtered.Add(messageInfo);
}

    // now work with the filtered collection

Viewing all articles
Browse latest Browse all 3862

Trending Articles