Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Get inbox count via rest or soap interface

  1. #1
    Dirk's Avatar
    Dirk is offline Moderator
    Join Date
    May 2006
    Location
    England.
    Posts
    927
    Rep Power
    10

    Question Get inbox count via rest or soap interface

    Hi, can I get the number of messages in the inbox of an account using rest or soap?

    Reason for this is I'm generating an info page that will be shown in the sales room on a large screen, it will show various info from various systems and is programmed in asp and ajax, I'd like to show the number of messages in the sales shared email account so people can see if they need to log into it to deal with messages. The messages are deleted or moved out of the inbox when actioned, so any messages in there, read or not will be something that needs actioning.

    I've never used either rest or soap before, so any tips on how to intergrate that into the javascript or asp function would be apprecated.

    Thanks.

  2. #2
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default GetFolderRequest

    Quote Originally Posted by Dirk View Post
    Hi, can I get the number of messages in the inbox of an account using rest or soap?
    Use SOAP. A <GetFolderRequest><folder l="2"/></GetFolderRequest> should give you what you want. Look at the "n" attribute on the topmost returned <folder> in the response.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  3. #3
    Dirk's Avatar
    Dirk is offline Moderator
    Join Date
    May 2006
    Location
    England.
    Posts
    927
    Rep Power
    10

    Default

    Ok, that's a starting point of sorts. I do appreciate the value of the "give a man a fish" addage, but the thing is, with that starting hint, the amount of research needed for me to work it out is likely to be too much for me to bother.

    I will try, of course, and I'll post a working example of exactly how to do it so others may benefit, but I'm currently working on an Asterisk system, which will also be intergrated into this status display and that's taking a phenominal amount of time and research, so what I hoped would be a short diversion may be a weeks research and learning.

    A working code snippet would point me towards a more concise field of research and I'd still learn how it all works in the end - dont get me wrong, I very much appreciate your response, and I know you have better things to do that to write my code for me, it's just frustrating at times that these things have such a steep learning curve.

    I have good SQL skills, good asp skills, I can read php and ruby, I can do reasonable ajax coding and I understand linux, but I have absolutley zero experience of soap and rest (that sounds odd!). I will get there, I will know it, but if you could offer a little more, I could get there faster.

    Looking at your post, it looks like some form of xml structure, but I dont see how to pass that request to zimbra, nor do I see how it would return the response.

    Yes, I'm being petulant, I know. I apologise for that, but when they said it wasnt going to be easy, I didnt realise it would be this hard

  4. #4
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default SOAP primer

    SOAP is a standardized XML-based RPC mechanism. It's the mechanism by which the AJAX client communicates with the Zimbra server. To get a sense of what a SOAP request looks like, turn on the AJAX client's debug window (search the forums for details on how to do this) and do something in the client -- fetch a message, mark a message as read, move a contact to the Trash.

    SOAP messages are sent to the SOAP servlet on the Zimbra server. I believe that the URL you want to send your SOAP requests to is http://example.com/service/soap . You should be able to find a SOAP library in the programming language of your choice to expedite this.

    The AJAX client explcitly asks for a JSON response because it's a JavaScript app and that's much easier for it to handle. You probably don't want to do this. Make sure that you don't include the <format type="js"/> element in the SOAP header.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  5. #5
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default Sample SOAP request

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
      <soap:Header>
        <context xmlns="urn:zimbra">
          <nosession/>
          <authToken>auth token from AuthResponse goes here</authToken>
        </context>
      </soap:Header>
      <soap:Body>
        <SearchConvRequest xmlns="urn:zimbraMail" sortBy="dateDesc" offset="0" limit="25" cid="-560" fetch="1" read="1" html="1">
          <query>in:inbox</query>
        </SearchConvRequest>
      </soap:Body>
    </soap:Envelope>
    Your request replaces SearchConvRequest and its children.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  6. #6
    Dirk's Avatar
    Dirk is offline Moderator
    Join Date
    May 2006
    Location
    England.
    Posts
    927
    Rep Power
    10

    Default

    Looks interesting, thanks Dkarp. Needless to say, I'm still none the wiser, but lets see what a day of googling and test code does. I'll try to work out all the generic stuff like the html, xml, js and soap by myself, but I may still need some zimbra specific assistance.

    The part about the auth token for instance, I've seen that mentioned in posts here before so I'm guessing I need to pass some code before this to specify the account I wish to read and send the response from that code into the soap header?

    Phew, lots to learn!

  7. #7
    Dirk's Avatar
    Dirk is offline Moderator
    Join Date
    May 2006
    Location
    England.
    Posts
    927
    Rep Power
    10

    Unhappy

    Well, a few hours in and I'm really beginning to think that the 's' in Soap should not stand for 'simple'

    I'd expect to be able to throw a few lines of code together and get a response, but everything I'm seeing so far is insanely complicated considering I'm just trying to do the SQL equivalent of
    Select Count(message) from account where account = 'thisone'

    Time to checkout the zimbra source code I guess...

  8. #8
    JoshuaPrismon is offline Zimlet Guru & Moderator
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    9

    Default

    Quote Originally Posted by Dirk View Post
    Well, a few hours in and I'm really beginning to think that the 's' in Soap should not stand for 'simple'

    I'd expect to be able to throw a few lines of code together and get a response, but everything I'm seeing so far is insanely complicated considering I'm just trying to do the SQL equivalent of
    Select Count(message) from account where account = 'thisone'

    Time to checkout the zimbra source code I guess...
    There are a lot of people who think that, hence REST.

    Something that I have found very useful is to get the latest version of Firebug for Firefox. Once you put it into debugging mode (click the icon in the lower status bar) you can see network traffic go back and forth. That includes the SOAP requests and the javascript responses. If you make your request look like their request, it will work.

    Most of the API's are documented in the soap.txt file in the ZimbraServer/Doc directory. Take a look at the ZimbraWebClient, not at the backend server.

  9. #9
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default zmmailbox option

    What I should have asked was what language you're using and whether there's a Zimbra install on the box.

    You can use the zmmailbox gf command to fetch this data, then just parse the results of executing the command.

    If you're in Java, you can use the com.zimbra.cs.zclient.ZMailbox class to fetch this data: new ZMailbox(...).getFolderByPath("Inbox").getUnreadCo unt().
    Bugzilla - Wiki - Downloads - Before posting... Search!

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

    Default

    Quote Originally Posted by dkarp View Post
    If you're in Java, you can use the com.zimbra.cs.zclient.ZMailbox class to fetch this data: new ZMailbox(...).getFolderByPath("Inbox").getUnreadCo unt().
    so, can we get information about accounts without accesing the SOAP way? Which libraries should we use to access this classes? Can this be done remotely?

    thanks in advance.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. REST and SOAP Documentation
    By omniplex in forum Developers
    Replies: 2
    Last Post: 10-19-2009, 03:23 AM
  2. SOAP or REST
    By bongkot in forum Developers
    Replies: 4
    Last Post: 08-01-2007, 04:13 AM
  3. Howto update contacts using REST interface?
    By tigger in forum Administrators
    Replies: 0
    Last Post: 05-23-2007, 03:26 AM
  4. Inbox unread message count is wrong
    By dhallweb in forum Administrators
    Replies: 6
    Last Post: 08-26-2006, 01:03 PM
  5. Where is the SOAP interface?
    By Robin Diederen in forum Developers
    Replies: 2
    Last Post: 04-19-2006, 12:09 AM

Posting Permissions

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