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 Display Modes
  #1 (permalink)  
Old 10-15-2008, 04:40 PM
New Member
 
Posts: 4
Default [SOLVED] catch events

Hello everybody,

I'm new in Zimbra and I read all day documentations, source code, the wiki and this forum about programming Zimlets to provide new functionality to this marvellous application. I understand, that I can mark a special part of a message with a regular expression like a email address, a order number and what else or drop something on a icon to do some action.
But I need to read some external sources as soon as the user clicks on the header of a message to open it for reading.
Can a Zimlet catch this event and supply the sender address as well?
If this is possible, can someone provide a snippet of code?
Unfortunate I could not find anything about this issue in the documentation and every Zimlet I saw so far used a method I described above.
Thanks in advanced.

By Michael
Reply With Quote
  #2 (permalink)  
Old 10-16-2008, 02:45 PM
New Member
 
Posts: 4
Default

Hello again,

today I had a closer look at the ZmZimletBase.js and the ZmMailMsg.js scripts. Voila I found the solution myself.
There is a prototype in the ZmZimletBase.js named "onMsgView" which will called every time you view a new message.

Here a example javascript:

Code:
function GetFromAddress() {
}

GetFromAddress.prototype = new ZmZimletBase();
GetFromAddress.prototype.constructor = GetFromAddress;

GetFromAddress.prototype.onMsgView =
function(msg, oldMsg){
	var from = msg.getAddress(AjxEmailAddress.FROM);
	alert(from);
};
And the appropriate XML File:

Code:
<zimlet name="GetFromAddress" version="1.0" description="Get the sender address and print an alert">
	<include>getFromAddress.js</include>
	<handlerObject>GetFromAddress</handlerObject>
	
</zimlet>
Hope this helps someone else...
Reply With Quote
  #3 (permalink)  
Old 06-24-2009, 11:41 PM
Intermediate Member
 
Posts: 19
Default

Quote:
Originally Posted by Liox View Post
Hello again,

today I had a closer look at the ZmZimletBase.js and the ZmMailMsg.js scripts. Voila I found the solution myself.
There is a prototype in the ZmZimletBase.js named "onMsgView" which will called every time you view a new message.

Here a example javascript:

Code:
function GetFromAddress() {
}

GetFromAddress.prototype = new ZmZimletBase();
GetFromAddress.prototype.constructor = GetFromAddress;

GetFromAddress.prototype.onMsgView =
function(msg, oldMsg){
	var from = msg.getAddress(AjxEmailAddress.FROM);
	alert(from);
};
And the appropriate XML File:

Code:
<zimlet name="GetFromAddress" version="1.0" description="Get the sender address and print an alert">
	<include>getFromAddress.js</include>
	<handlerObject>GetFromAddress</handlerObject>
	
</zimlet>
Hope this helps someone else...
Hey Liox , Thanx for the post it helped me a lot ..
But i didnt create a new zimlet for that ... Since its giving error after deploying .. I am new to zimlets . i created the XML and the JS file as you have posted ...
Am getting the following error in mailbox.log

2009-06-25 09:54:31,270 INFO [btpool0-7] [name=zimbra;ip=10.200.220.186;] soap - DeployZimletRequest
2009-06-25 09:54:31,272 INFO [Thread-480] [] zimlet - deploy
java.io.FileNotFoundException: zimlet description not found: GetFromAddress.xml
at com.zimbra.cs.zimlet.ZimletFile.initZimletDescript ion(ZimletFile.java:199)
at com.zimbra.cs.zimlet.ZimletFile.initialize(ZimletF ile.java:191)
at com.zimbra.cs.zimlet.ZimletFile.<init>(ZimletFile. java:146)
at com.zimbra.cs.service.admin.DeployZimlet$DeployThr ead.run(DeployZimlet.java:96)
at java.lang.Thread.run(Thread.java:595)

if u can plz explain me the above .

so what i did is used the function in some other zimlet (ie i edited another zimlet ) and am getting the from address from there .

Another Querry ::
Is it possible to get the From address or the Subject without using the onMsgView Function .
What would u suggest if i need these values(from and subject) inside an Already existing function .

Many Thanx in Advance
Reply With Quote
  #4 (permalink)  
Old 06-25-2009, 01:07 AM
Member
 
Posts: 12
Default

Hello Friends,

I am new bee in zimlet and need to implement zimlet to move duplicate emails to Duplicate folder.

I have found one solution for develop zimlet in production environment with zimbra desktop.

Please review below link which will help to develop zimlet in faster and easy way
ZimletDevSetup - Zimbra :: Wiki
Reply With Quote
Reply


Thread Tools
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.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0