Get message ID in URL when selecting message in web client

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Posts: 2
Joined: Wed Jun 14, 2017 1:39 pm

Get message ID in URL when selecting message in web client

Postby pat » Wed Jun 14, 2017 8:46 pm

I'm using zimbra, that means its web client, for many years and so far I've always looked at zimbra from an end user's perspective only. Just a disclaimer in case my questions are that much "beginners level" ;-)

First of all I've seen how the anchors change when using the web client. As an example, lets assume the entry point of the web client is or short /zimbra, then after login the browser is at /zimbra/#1. While navigating through different emails the browser stays at /zimbra/#1 but on every change of tab the anchor gets incremented to /zimbra/#2, then /zimbra/#3, and so on. I assume that's to support navigation with browser back and forward buttons.
When I double click a message it gets displayed within a new tab and the browser is at the next anchor, for example /zimbra/#5.
I get the exact same view when navigating with the browser to /zimbra/?id=4711. (Assuming the ID of the message double clicked before was 4711. The ID can be determined by choosing "Show Original" in the message's context menu or under the drop down button "Actions".)

Now my question: is there already a way to open or select or ... a message in a way that I get the message ID in the URL? Or is there a (hopefully simple) way to extend the web client with a new action that would do so?

Why do I care? I'd like a smooth integration with a 3rd party tool (Things to be more specific) for managing ToDos. Once I could open or select a message in a way that the browser points directly to where that very same message is shown, I only need to use a keyboard shortcut and I get a new entry in Things with a useful backlink that even works after I move the message to the trash or some other folder.

Looking forward to any hints, ideas, suggestions or even better solutions

Posts: 2
Joined: Wed Jun 14, 2017 1:39 pm

Re: Get message ID in URL when selecting message in web client

Postby pat » Thu Jun 22, 2017 9:46 pm

since there seems not to be a lot of traffic - or at least not many responses - on this forum, I answer my own question after digging through the scarce information in the zimlet developer guide and mainly do JS the end, the solution is pretty trivial (the more surprising that there was no answer at all from any experienced zimbra or zimlet developer).
But to the interesting part, these two snippets are not perfect (e.g. the button is shown independent of the context) but does what it ought to do:

Code: Select all

<zimlet name="foo" version="1.0" description="Adds button to the toolbar that opens mail by its ID.">


Code: Select all

foo_HandlerObject = function() {
foo_HandlerObject.prototype = new ZmZimletBase;
foo_HandlerObject.prototype.constructor = foo_HandlerObject;
foo_HandlerObject.prototype.initializeToolbar = function(app, toolbar, controller, viewId) {
   var buttonParams = {
         text    : "Open by ID",
         tooltip: "This button opens selected mail by ID",
         index: toolbar.opList.length // position of the button
   var button = toolbar.createOp("openbyid_ZIMLET_TOOLBAR_BUTTON", buttonParams);
   button.addSelectionListener(new AjxListener(this, this._showSelectedMail, controller));   
foo_HandlerObject.prototype._showSelectedMail = function(controller) { ("/zimbra?id=" + controller.getMsg().id, "perid","menubar=1,resizable=1,width=800,height=600");

Hope it helps somebody in the future...

Return to “Developers”

Who is online

Users browsing this forum: Google [Bot] and 2 guests