0

Can't get the event MessagesArrived and CountChanged to fire for GMail.. When new emails arrived at the inbox those events just won't fired. Is this not supported for GMail? or is it my wrong implementation?

Your inputs are much appreciated.

Kagawa
  • 1,319
  • 2
  • 21
  • 33

1 Answers1

2

I would recommend against using the MessagesArrived event, it was an attempt at making things easier but it's not very good.

CountChanged only fires when GMail sends a line like:

* 20 EXISTS

If GMail is not sending that, then MailKit cannot know that the count has changed.

To check for yourself, follow the directions in the MailKit FAQ to set up a ProtocolLogger.

jstedfast
  • 35,744
  • 5
  • 97
  • 110
  • Try using `NoOp()`. IMAP servers only emit events in response to commands, so in order to get a notification about the number of messages changing in the folder, you need to send a command. The `NOOP` command is the perfect command for this because it has no other effect. – jstedfast Jan 31 '17 at 14:48
  • 1
    Your other option is to use `Idle()` which changes the mode for the IMAP connection to allow the server to push unsolicited notifications to the client as they happen. – jstedfast Jan 31 '17 at 14:49