Results 1 to 8 of 8

Thread: How to get the messages in a conversation

  1. #1
    Join Date
    Apr 2008
    Posts
    25
    Rep Power
    7

    Default How to get the messages in a conversation

    I am trying to make a zimlet which sends items dropped on a panel item to another server.

    When I drag a mail message to the panel item I always get a conversation object, even if it is one message. How do I retrieve the most recent mail message?

    I have looked in the javascript libraries for the ZmConv class but I do not know how this class got initialized. I can get the numMsgs and the fragment, but how do I retrieve the messages and if I have the messages, how do I get the body?

  2. #2
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

    Default

    You can look at this zimlet code (retrieve messages but in a jsp page):
    http://www.zimbra.com/forums/zimlets...-txt-file.html

    How do I retrieve the most recent mail message?
    After you retrieve your ZmConv object, you maybe can use the method getFirstHotMsg to retrieve a ZmMailMsg object, and after you can retrieve the body with the body param of ZmMailMsg (obj.body).

  3. #3
    Join Date
    Apr 2008
    Posts
    25
    Rep Power
    7

    Default

    When I try to execute the getFirstHotMsg I get the following in the error console:

    Error: conversation.getFirstHotMsg is not a function
    Source File: https://------/service/zimlet/_dev/n...=1211374524110
    Line: 74

    i have also tried to execute the toString() function but I keep getting Object back instead of the ZkConf text. But if I execute numMsgs and fragment do return values!

  4. #4
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

    Default

    It is not normal it don't work, you lack a parameter.
    Here is the method from ZmConv.js (source code from version 5.0.2) :
    Code:
    /**
     * Returns the first matching msg of this conv, loading the conv msg list if necessary. If the
     * msg itself hasn't been loaded we also load the conv. The conv load is a SearchConvRequest
     * which fetches the content of the first matching msg and returns it via a callback. If no
     * callback is provided, the conv will not be loaded - if it already has a msg list, the msg
     * will come from there; otherwise, a skeletal msg with an ID is returned. Note that a conv
     * always has at least one msg.
     * 
     * @param params	[hash]	hash of params:
     *        query				[string]*		query used to retrieve this conv
     *        sortBy			[constant]*		sort constraint
     *        offset			[int]*			position of first msg to return
     *        limit				[int]*			how many msgs to return
     * @param callback			[AjxCallback]*	callback to run with results
     */
    ZmConv.prototype.getFirstHotMsg =
    function(params, callback) {
    	
    	var msg;
    	params = params || {};
    
    	if (this.msgs && this.msgs.size()) {
    		msg = this.msgs.getFirstHit(params.offset, params.limit);
    	}
    
    	if (callback) {
    		if (msg && msg._loaded) {
    			callback.run(msg);
    		} else {
    			var respCallback = new AjxCallback(this, this._handleResponseGetFirstHotMsg, [params, callback]);
    			params.getFirstMsg = true;
    			this.load(params, respCallback);
    		}
    		return;
    	} else {
    		// do our best to return a "realized" message by checking cache
    		if (!msg && this.msgIds && this.msgIds.length) {
    			var id = this.msgIds[0];
    			msg = appCtxt.getById(id) || new ZmMailMsg(id);
    		}
    		return msg;
    	}		
    };

  5. #5
    Join Date
    Apr 2008
    Posts
    25
    Rep Power
    7

    Default

    More info:

    I have tried to do obj instanceof ZmConf to check if it knows that it is a subtype of that class but then I get the error that ZmConf is not defined.

    I have really no idea what is going on!
    The objects passed to doDrop are of type ZmMailMsg, ZmConf, etc. or not?

  6. #6
    Join Date
    Apr 2008
    Posts
    25
    Rep Power
    7

    Default

    Even if I pass the arguments to getFirstHotMsg it says it is not a function. Somehow it seems that the obj passed to doDrop is not really a ZmConf class

  7. #7
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

    Default

    It is not ZmConf but ZmConv.

  8. #8
    Join Date
    Apr 2008
    Posts
    25
    Rep Power
    7

    Default

    I am still at loss, I really do not understand what type of objects are returned by the different methods.

    Now i tried the following with a ZmConv object:

    Code:
    	var ajxCallback = new AjxCallback(this, this._done_getMsgsForConv, conversation);
    	this.getMsgsForConv( ajxCallback, conversation );
    and in the callback:
    Code:
    xxxxx.prototype._done_getMsgsForConv = function( conversation, message )
    {
    	//Process message
    	alert( "body content: " + message.getBodyContent() );
    };
    The getBodyContent function is defined in ZmMailMsg but when I call the function I get the error:

    Code:
    Error: message.getBodyContent is not a function
    What do all these methods return!!! I just want to have the full email details so that I can create a rpc call to another service.

Similar Threads

  1. [SOLVED] Re-creating the spam training e-mail account
    By richard-hdd in forum Administrators
    Replies: 21
    Last Post: 03-20-2012, 07:34 AM
  2. New messages not showing up in outlook
    By bersrker in forum Zimbra Connector for Outlook
    Replies: 4
    Last Post: 01-16-2007, 07:17 AM
  3. Reading Pane in Conversation View
    By bkonia in forum Users
    Replies: 12
    Last Post: 12-18-2006, 10:13 AM
  4. upgrade to 4.0.3 antispam does'nt work
    By lucanannipieri in forum Administrators
    Replies: 14
    Last Post: 11-07-2006, 02:56 AM
  5. Spam assassain not traiing properly!
    By Mike T in forum Administrators
    Replies: 1
    Last Post: 10-09-2006, 01:34 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
  •