jstedfast / MailKit

A cross-platform .NET library for IMAP, POP3, and SMTP.

Home Page:http://www.mimekit.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'MessagesArrived' Event

OsamaAlRashed opened this issue · comments

I noticed in the provided example:(https://github.com/jstedfast/MailKit/blob/master/Documentation/Examples/ImapIdleExample.cs) how to handle receiving new messages. However, I couldn't find a 'MessagesArrived' event in the MailKit library itself, even though it does have 'CountChanged', 'MessageFlagsChanged', and 'MessageExpunged' events. It seems inconvenient to write around 250 lines of code to achieve the desired functionality.
Is there a specific reason why the library doesn't include a 'MessagesArrived' event?

MailKit does not have a MessagesArrived event because there is no corresponding IMAP protocol feature.

The sample you pointed to is just a sample to show how to make limited use of the IDLE command for IMAP.

It's also a good way to keep a connection alive using NOOP.

If you were writing a real email client, you'd want to listen to more events inside that code to update state of cached messages.

This is not something that can just be added to MailKit because there's no way to know exactly how your project wants to use it.