IMAP client Mailbox property ContainsNewMessages is alwyas false

0

I'm trying to retrieve mailbox information by selecting the mailbox and then accessing the WorkingMailboxInfo.  I've tried this with gmail and yahoo accounts and I noticed that ContainsNewMessages is always false, NewUnseenMessages and RecentMessages are always 0.  First I tried just single calls and then I thought maybe the client has to be instantiated in order to detect changes in state.  Still, even if new emails arrive while the loop is running the values are still unchanged.

I'd appreciate anny help.

Regards,

Ciprian

 

[code lang='c#']

            var client = new ImapClient();
            client.Connect("imap.gmail.com", 993, SecurityMode.Implicit);
            client.Authenticate("xyz@gmail.com", "...");

            var n = 0;
            while (n < 20)
            {
                if (client.WorkingMailbox != null)
                    client.Deselect();
                client.Select("INBOX");

                Console.WriteLine(client.WorkingMailbox.ContainsNewMessages);
                Console.WriteLine(client.WorkingMailbox.NewUnseenMessages);
                Console.WriteLine(client.WorkingMailbox.RecentMessages);
                
                n++;
                Thread.Sleep(1000);
            }

           client.Disconnect();

[/code

edited 11/16/2017 12:41:36 AM
asked 2/20/2014 6:23:49 PM
add a comment

2 Answers

0
Have you tried the `Noop` method? That one is for checking for any updates (new message, ...) from the server.
edited 12/4/2017 10:44:09 PM
answered 11/16/2017 12:41:36 AM
add a comment
0

Thanks for your response.  I found this works with our Exchange server but doesn't work with Gmail, Yahoo, Hotmail.  

  • TotalMessages, NotSeenMessages are both updated on mailbox re-select.  This hapens on all four servers I listed above.
  • NewUnseenMssages (which should really be FirstSeenMessage) is updated on mailbox re-select.  This only works for Exchange and Hotmail.
  • ContainsNewMessages, RecentMessages are updated on client re-connect (and mailbox select).  This works only for Exchange.
  • Noop() always returns False for Gmail, Yahoo, Hotmail.  I didn't try Exchange, it probably works there.

 

Again, this is all in the context of IMAP server receiving new messages.

 

 
answered 11/16/2017 12:41:36 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged imap mail or ask your own question.