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

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 05-21-2008, 02:07 AM
Active Member
 
Posts: 25
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?
Reply With Quote
  #2 (permalink)  
Old 05-21-2008, 02:47 AM
Zimlet Guru & Moderator
 
Posts: 288
Default

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

Quote:
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).
Reply With Quote
  #3 (permalink)  
Old 05-21-2008, 06:04 AM
Active Member
 
Posts: 25
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!
Reply With Quote
  #4 (permalink)  
Old 05-21-2008, 06:23 AM
Zimlet Guru & Moderator
 
Posts: 288
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;
	}		
};
Reply With Quote
  #5 (permalink)  
Old 05-21-2008, 07:25 AM
Active Member
 
Posts: 25
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?
Reply With Quote
  #6 (permalink)  
Old 05-21-2008, 07:29 AM
Active Member
 
Posts: 25
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
Reply With Quote
  #7 (permalink)  
Old 05-21-2008, 08:51 AM
Zimlet Guru & Moderator
 
Posts: 288
Default

It is not ZmConf but ZmConv.
Reply With Quote
  #8 (permalink)  
Old 05-22-2008, 04:38 AM
Active Member
 
Posts: 25
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.
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.