Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-05-2006, 02:57 PM
Senior Member
 
Posts: 58
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?
Reply With Quote
  #2 (permalink)  
Old 06-05-2006, 04:48 PM
Zimbra Employee
 
Posts: 4,792
Default

GetInfoResponse should have this in the Header refresh block. It will have an unread count for each folder.
__________________
Bugzilla - Wiki - Downloads - Offline Client
Reply With Quote
  #3 (permalink)  
Old 06-22-2006, 11:28 PM
Zimbra Employee
 
Posts: 1,434
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!
Reply With Quote
  #4 (permalink)  
Old 06-23-2006, 10:47 AM
Senior Member
 
Posts: 58
Default Thanks

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

Is there an particular advantage to one way over another?
Reply With Quote
  #5 (permalink)  
Old 06-24-2006, 03:51 PM
Zimbra Employee
 
Posts: 4,792
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.
__________________
Bugzilla - Wiki - Downloads - Offline Client
Reply With Quote
  #6 (permalink)  
Old 06-26-2006, 04:32 PM
Senior Member
 
Posts: 58
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..
Reply With Quote
  #7 (permalink)  
Old 06-26-2006, 10:23 PM
Zimbra Employee
 
Posts: 4,792
Default

That is exatly what the web client does.
__________________
Bugzilla - Wiki - Downloads - Offline Client
Reply With Quote
  #8 (permalink)  
Old 03-19-2007, 08:33 AM
Member
 
Posts: 12
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
Reply With Quote
  #9 (permalink)  
Old 03-22-2007, 08:15 AM
Member
 
Posts: 10
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?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.