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 03-21-2006, 01:04 PM
Intermediate Member
 
Posts: 21
Default Extra Mime Parts?

Hey Guys,

I was playing around with modifying the message via my Zimlet javascript. My goal was to append some additional html or text onto the message that would normally be hidden to the user (so they can't modify it). Here's the code that I used:
var videoHolder = new ZmMimePart();
videoHolder.setContentType(ZmMimeTable.TEXT_HTML);
videoHolder.setContent("<h3>This would be my video rider</h3>");
var videoText = new ZmMimePart();
videoText.setContentType(ZmMimeTable.TEXT_PLAIN);
videoText.setContent("Plain Text Video Description");

composerView.addMimePart(videoText);
composerView.addMimePart(videoHolder);
The code worked, in a way. When I triggered this code and sent off the message, the original message was 'lost'. All that would be visible was the extra mime part that I added (either one depending on my client's view preference, so both html and plain types were visible in the same message).

Did I do something wrong or is there a bug in the code? My assumption is that extra mime parts would not override the original message. BTW, when I say original message I mean the message that the user was composing, not one that they would be replying to.

Cheers,
Marty
Reply With Quote
  #2 (permalink)  
Old 03-21-2006, 06:21 PM
Zimbra Employee
 
Posts: 4,792
Default

Well here's the logic:

Code:
	// set up message parts as necessary
	var top = new ZmMimePart();

	if (this._composeMode == DwtHtmlEditor.HTML) {
		top.setContentType(ZmMimeTable.MULTI_ALT);

		// create two more mp's for text and html content types
		var textPart = new ZmMimePart();
		textPart.setContentType(ZmMimeTable.TEXT_PLAIN);
		textPart.setContent(this._htmlEditor.getTextVersion());
		top.children.add(textPart);

		var htmlPart = new ZmMimePart();
		htmlPart.setContentType(ZmMimeTable.TEXT_HTML);
		htmlPart.setContent(this._htmlEditor.getContent());
		top.children.add(htmlPart);
	} else {
		var textPart = this._extraParts ? new ZmMimePart() : top;
		textPart.setContentType(ZmMimeTable.TEXT_PLAIN);
		textPart.setContent(this._htmlEditor.getContent());

		if (this._extraParts) {
			top.setContentType(ZmMimeTable.MULTI_ALT);
			top.children.add(textPart);
		}
	}

	// add extra message parts
	if (this._extraParts) {
		for (var i = 0; i < this._extraParts.length; i++) {
			var mimePart = this._extraParts[i];
			top.children.add(mimePart);
		}
	}
Did you try this both in HTML compose mode and test compose mode? Seems the logic is a bit different for the two cases.

What I'd recommend is you do your test with Venkman (JS debugger for Firefox) and try to figure out exactly at which point the extra parts overwrite the main message. From a quick inspection the code looks right.
__________________
Bugzilla - Wiki - Downloads - Offline Client
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.