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 05-02-2011, 03:03 AM
Special Member
 
Posts: 117
Default Want to hook mail message delete event.

Hello Guys,

I want to do some task when the user delete a mail message from zimbra. Can anybody guide me how can I do that?

Thanks in advanced.
Dhaval.
Reply With Quote
  #2 (permalink)  
Old 05-02-2011, 09:32 PM
Zimbra Employee
 
Posts: 70
Default

You can write your own zimbra server extension (» Zimbra :: Blog) which listens for deletion of mail message items. The extension would need to implement com.zimbra.cs.mailbox.MailboxListener interface.
Reply With Quote
  #3 (permalink)  
Old 05-02-2011, 10:06 PM
Special Member
 
Posts: 117
Default

Quote:
Originally Posted by vmahajan View Post
You can write your own zimbra server extension (» Zimbra :: Blog) which listens for deletion of mail message items. The extension would need to implement com.zimbra.cs.mailbox.MailboxListener interface.
Thank you mate for the link. I will look at it and let you know.
Reply With Quote
  #4 (permalink)  
Old 05-02-2011, 10:38 PM
Special Member
 
Posts: 117
Default

Quote:
Originally Posted by vmahajan View Post
You can write your own zimbra server extension (» Zimbra :: Blog) which listens for deletion of mail message items. The extension would need to implement com.zimbra.cs.mailbox.MailboxListener interface.
I couldn't find the source code of the interface com.zimbra.cs.mailbox.MailboxListener. Please connect me to the source code of the com.zimbra.cs.mailbox package.

Thanks.
Reply With Quote
  #5 (permalink)  
Old 05-03-2011, 01:59 AM
Special Member
 
Posts: 117
Default

I've created following java class and make a jar file of it. Added the line in menifest file and then deployed it under <zimbra install dir>/lib/ext/<my extension>/my.jar

Now everything is working fine. I am getting events on delete mail message. But how can I fetch the path of the blob file which attached with the email?


Code:
package my.listener;

import com.zimbra.cs.extension.ZimbraExtension;
import com.zimbra.cs.mailbox.MailItem;
import com.zimbra.cs.mailbox.MailboxListener;
import com.zimbra.cs.mailbox.OperationContext;
import com.zimbra.common.localconfig.Logging;
import com.zimbra.common.service.ServiceException;


public class MyDeleteMailListener extends MailboxListener implements ZimbraExtension{

	@Override
	public void handleMailboxChange(String accountId, int changedTypes,
			OperationContext octxt) {		
		System.out.println("MyDeleteMailListener - accountid " + accountId + " changeTypes " + changedTypes + " Operationcontext " + octxt);
		Logging.warn("MyDeleteMailListener - accountid " + accountId + " changeTypes " + changedTypes + " Operationcontext " + octxt);
	}

	@Override
	public int registerForItemTypes() {
		Logging.warn("MyDeleteMailListener - Registering type");
		return MailItem.TYPE_MESSAGE;
	}

	@Override
	public String getName() {
		Logging.warn("MyDeleteMailListener - getName");
		return "Stalker Extension";
	}

	@Override
	public void init() throws ServiceException {
		Logging.warn("MyDeleteMailListener - in init");
                register(this);
	}

	@Override
	public void destroy() {
		Logging.warn("MyDeleteMailListener - in desstroy");
	}

}

Last edited by stalker; 05-03-2011 at 09:52 PM..
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.