This project is read-only.

How to get the total messages inside an IMAP mailbox?

Jun 17, 2011 at 5:56 AM

I can see from the IMAP reference that when a folder is selected, the following will be the response. 

z SELECT INBOX
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk
$Label2 $Label1 $Label3 $Label4 $Label5 Junk $Forwarded $MDNSent)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted
\Seen NonJunk $Label2 $Label1 $Label3 $Label4 $Label5 Junk
$Forwarded $MDNSent \*)]
* 42 EXISTS
* 0 RECENT
* OK [UNSEEN 41]
* OK [UIDVALIDITY 1060587836]
* OK [UIDNEXT 12645]
z OK [READ-WRITE] Completed

SelectExamineResponse has the does not have information about EXISTS on the Info property.

How can i get thet EXISTS value?

I am trying again this library after a short gap. can you help?.

 

 

Jun 17, 2011 at 3:56 PM

Hi suhair,

glad to have you back ;)

The "Select" statement is triggering a status update. Since status updates can be pushed by the server alongside every command and anytime, it was implemented as an event.

You can subscribe to the StatusUpdateReceived event before calling any commands on the client.

The event arguments contain all possible status changes, including the "Exist" property.

Regards 

Alex

Jun 17, 2011 at 6:21 PM

ok. Then why other properties like RECENT is available SelectExamineResponse itself?.

Right now I am issuing ManagedCommand (why you changed this to ManagedCommand from RawCommand by the way?) and parsing the EXISTS through regular expression.

In short StatusUpdateReceived event is the only shortest way to get the total messages inside a folder?.

Jun 17, 2011 at 9:30 PM
suhair wrote:

ok. Then why other properties like RECENT is available SelectExamineResponse itself?.

Although the select response seems to be a single block, it is devided into 2 seperate responses.

These are the responses from the select itself

* OK [UNSEEN 41]
* OK [UIDVALIDITY 1060587836]
* OK [UIDNEXT 12645]
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted)]

while these are regular status response items

* 42 EXISTS
* 0 RECENT
* 41 UNSEEN 
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk)]

Some of the response items are redundant to the select response, therefor both responses have similar but not identical properties. Hope this makes things a little clearer. It is possible that we mixed up some of the values, if you find a defect, please let me know.

I renamed the RawCommand to ManagedCommand, since it better seperates the BlankCommand from the RawCommand, the name comes from the fact, that the ManagedCommand creates and adds the session identification automatically to the command string, while the BlankCommand is truly blank.

Regards

Alex

Jun 19, 2011 at 1:28 AM

I changed the select statement for the latest change set.

It now publishes all informations in its response and suppresses status updates for the time being.

In addition the status update event now operates on the same object, the MailboxInfo.