facebooktwittermenuarrow-up

GemBox Support Forum

How do I get only UNSEEN messages with IMAP?

I am testing out Gembox for a client and trying to implement a solution where I get all the emails from a certain inbox to parse and turn into database records. The thing is, I only need each message once, and by default I just get the whole inbox each time, seen and unseen.

I’ve seen this example but that only comes back with the number of results. I need the actual messages so I can parse subject and body.

The project is in VB.NET

Thanks.

Hi Lazar,

You need to use the search method (as shown in that example) and then retrieve the emails by using its result (either email numbers or uids).

In other words, try this:

For Each uid As String In imap.SearchMessageUids("UNSEEN")
    Dim unreadEmail As MailMessage = imap.GetMessage(uid)
    ' TODO ...
Next

Also, note that by using GetMessage the retrieved emails will automatically be marked as read. If you don’t want that then use PeekMessage instead.

Regards,
Mario

Duh! So simple. Thank you very much.

I get this Error:
GemBox.Email.FreeLimitReachedException: “Entity content size exceeds free limit.”

Hi Robert,

Note that GemBox.Email in Free mode is limited to 50 sent or received messages and message attachments up to 50 KB.
For more information, please check the Evaluation and Licensing help page.

Regards,
Mario