Results 1 to 9 of 9

Thread: Obtaining unread message counts

  1. #1
    Coilcore is offline Senior Member
    Join Date
    Nov 2005
    Posts
    58
    Rep Power
    8

    Default Obtaining unread message counts

    I've tried a few ways to get the number of unread messages in the inbox using SOAP SearchRequest and seem to be having some problems.

    I'm sending a SearchRequest for "in:inbox is:unread"

    I started out trying to use the 'hits' attribute which was shown in the soap.txt in the Search example, but that doesn't seem to actually exist in the SearchResponses I get back. So instead I'm literally counting results (which is obviously the wrong way but I wanted to get something working), but that also seems inaccurate because of some form of pagination limits the results on large mailboxes.

    What would be the proper way to find the number of unread messages for a user?

  2. #2
    KevinH is offline Zimbra Employee
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,792
    Rep Power
    17

    Default

    GetInfoResponse should have this in the Header refresh block. It will have an unread count for each folder.

  3. #3
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,434
    Rep Power
    10

    Default GetFolderRequest is better...

    The best way to get info on the folder hierarchy is to issue a GetFolderRequest SOAP command. I believe the folder unread count is in the "u" attribute on each <folder>...
    Bugzilla - Wiki - Downloads - Before posting... Search!

  4. #4
    Coilcore is offline Senior Member
    Join Date
    Nov 2005
    Posts
    58
    Rep Power
    8

    Default Thanks

    We actually implemented this using Kevin's suggestion for GetInfoResponse.

    Is there an particular advantage to one way over another?

  5. #5
    KevinH is offline Zimbra Employee
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,792
    Rep Power
    17

    Default

    Dan's way is more reliable if your expecting to make this request over and over during a session. Mine is how the web client does thing and does have more over head since lots of other data is returned. In the web client's case we need that data for a single call is best. If you just need unread counts and nothing else the GetFolderRequest is a better call to make.

  6. #6
    Coilcore is offline Senior Member
    Join Date
    Nov 2005
    Posts
    58
    Rep Power
    8

    Default

    We're using the response headers and inspecting the unread message count and updating our count whenever it changes. If theres no activity for a 10 minute period we are sending a NoOp request to get a set of headers. This seems a little more dynamic than polling with a GetFolderRequest (though a little more complex).

    I'm guessing this is what the mail client does as well.
    Last edited by Coilcore; 06-27-2006 at 10:45 AM.

  7. #7
    KevinH is offline Zimbra Employee
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,792
    Rep Power
    17

    Default

    That is exatly what the web client does.

  8. #8
    gigapipe is offline Member
    Join Date
    Mar 2007
    Posts
    12
    Rep Power
    7

    Default portlet with unread messages count

    Hi,

    in our case we have integrated Liferay Portal with Zimbra using the preauthentication with success, but we'd like to put in our portlet the number of unread messages of each user logged in.

    I've never used SOAP and web-services reason why I dont know how to build a request to Zimbra's server in order to use the GetInfoRequest.

    Could you give me a hand with some examples or info, please?

    Thanks

    Felipe

  9. #9
    jrramon is offline Member
    Join Date
    Mar 2007
    Posts
    10
    Rep Power
    7

    Default

    This is what we are doing...

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"></context>
    	</soap:Header>
    	<soap:Body>
    		<AuthRequest xmlns="urn:zimbraAccount">
    			<account by="name">youremail@com.com</account>
    			<preauth timestamp="XXXXX" expires="0">XXXXXXXXXXXXXXXXXXXXXXXX</preauth>
    		</AuthRequest>
    	</soap:Body>
    </soap:Envelope>
    This way you can connect (with preauth identificacion, so no userīs password is required).
    The response is this way:
    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    	<soap:Header>
    		<context xmlns="urn:zimbra">
    			<sessionId id="44">44</sessionId>
    			<refresh>
    				<mbx s="627"/>
    				<tags/>
    				<folder l="11" name="USER_ROOT" id="1">
    					<folder view="appointment" f="#" rest="http://localhost/home/youremail@com.com/Calendar/" l="1" name="Calendar" id="10"/>
    					<folder view="message" l="1" name="Chats" id="14"/>
    					<folder view="contact" rest="http://localhost/home/youremail@com.com/Contacts/" l="1" name="Contacts" id="7"/>
    					<folder view="message" l="1" name="Drafts" id="6"/>
    					<folder view="contact" rest="http://localhost/home/youremail@com.com/Emailed%20Contacts/" n="1" l="1" name="Emailed Contacts" id="13"/>
    					<folder view="message" n="1" l="1" name="Inbox" id="2"/>
    					<folder view="message" l="1" name="Junk" id="4"/>
    					<folder view="wiki" rest="http://localhost/home/youremail@com.com/Notebook/" l="1" name="Notebook" id="12"/>
    					<folder view="message" u="1" f="u" n="1" l="1" name="Sent" id="5"/>
    					<folder view="task" f="#" rest="http://localhost/home/youremail@com.com/Tasks/" l="1" name="Tasks" id="15"/>
    					<folder l="1" name="Trash" id="3"/>
    				</folder>
    			</refresh>
    			<change token="104"/>
    		</context>
    	</soap:Header>
    	<soap:Body>
    		<AuthResponse xmlns="urn:zimbraAccount">
    			<authToken>0_307762e8e2363c386f745ffd95e85df3ebf9adc3_69643d33363a32666236303338622d363735302d346131382d616665652d6335663735353330383934633b6578703d31333a313137343734363638333832323b</authToken>
    			<lifetime>172800000</lifetime>
    			<sessionId id="44">44</sessionId>
    		</AuthResponse>
    	</soap:Body>
    </soap:Envelope>

    so you can get unread messages this way: (Java)
    Code:
    //smAut is SOAPMessage with the response 
    NodeList vistas = smAut.getSOAPHeader().getElementsByTagName("folder");
    	        int noLeidos =0;
    	        for (int n=0; n<vistas.getLength();n++)
    	        {
    	        	Node us = vistas.item(n).getAttributes().getNamedItem("u");
    	        	if (us!=null)
    	        		noLeidos += Integer.parseInt(us.getFirstChild().getNodeValue());
    	        }
    Whith that unread messages can be read.

    Our problem is now to use another command, when we send the authentication in AuthResponse, Zimbra always return SERVICE UNKNOWN. any help?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 07-19-2007, 02:00 AM
  2. Replies: 1
    Last Post: 04-24-2007, 09:36 PM
  3. Inbox unread message count is wrong
    By dhallweb in forum Administrators
    Replies: 6
    Last Post: 08-26-2006, 01:03 PM
  4. Replies: 42
    Last Post: 08-11-2006, 09:50 AM
  5. Replies: 4
    Last Post: 08-10-2006, 10:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •