Subject: IMAP client Mailbox property ContainsNewMessages is alwyas false
Date: 2014-02-20 18:23:49
From: Ciprian Malaia
Source: imap-client-mailbox-property-containsnewmessages-alwyas-false
----------------------------------------------------------------------

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

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index