1

This is my simplified code:

using ImapX;

private ImapClient Client { get; set; }

private void SetupListener(string mail, string password)
{
    Client = new ImapClient();
    Client.Connect("imap.gmx.net", 993, true);
    // Client.IsConnected == true

    Client.Login(mail, password);
    // Client.IsAuthenticated == true

    // Test 1
    Client.Folders.Inbox.OnNewMessagesArrived += MessageArrived;
    // Test 2
    Client.OnNewMessagesArrived += MessageArrived;
}

private void MessageArrived(object sender, IdleEventArgs e)
{
    MessageBox.Show("This never pops up!");
}

This already shows up my problem. MessageArrived is never getting called. I tried this out with 2 different providers. Same problem for both (t-online.de and gmx.net).

Any idea whats going on in here?
The documentation isn't showing up anything else than this.

C4d
  • 3,183
  • 4
  • 29
  • 50
  • How does this code show that `MessageArrived` doesn't get called? – Enigmativity Aug 29 '17 at 13:07
  • I've written the code shows up my problem. Then I "told" you that i doesn gets executed. Anyway, that's not the problem in here. – C4d Aug 29 '17 at 13:09
  • @AntonKomyshan Sir, I love you. I got mad for hours with this. Starting the idle-process seriously solved this. Even if this is a small thing, that wasn't mentioned in the documentation. Maybe you should post it as an answer? There's nothing similar as a question available. – C4d Aug 29 '17 at 13:10

1 Answers1

1

Please, try to call Client.Folders.Inbox.StartIdling(); after subscribing.

This will help you to receive messages in real time.

I refer to the documentation here

ImapX supports idle, so you can receive new messages just-in-time. Once new messages arrive in the current folder, they will be downloaded automatically and an event will be fired.

Anton Komyshan
  • 1,377
  • 10
  • 21
  • 1
    Oh this "so you can" part is the one that says you have to use idle to be able to use the events. Thank you very much! – C4d Aug 29 '17 at 13:57