Results 1 to 7 of 7

Thread: Hook code on delete, send, receive and move email

  1. #1
    stalker is offline Special Member
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default Hook code on delete, send, receive and move email

    I want to log some information when user delete, receive, send and move an email in zimbra. For that I've tried to write a zimbra extension. See following code. But I couldn't find a way to differentiate the events. The extension is getting call every time but no way to say that whether it is delete or move or send email event.

    Can anybody shed some more light?

    Code:
    package my.listener;
    
    import com.zimbra.common.service.ServiceException;
    import com.zimbra.cs.extension.ExtensionException;
    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.cs.session.PendingModifications;
    
    public class MyDeleteMailListener extends MailboxListener implements ZimbraExtension{
    
    	@Override
    	public void destroy() {
    		System.out.println("MyDeleteMailListener - In Destroy");
    		
    	}
    
    	@Override
    	public String getName() {
    		return "MyDeleteMailListener";
    	}
    
    	@Override
    	public void init() throws ExtensionException, ServiceException {
    		System.out.println("MyDeleteMailListener - In Init and registering");
    		register(this);
    	}
    
    	@Override
    	public void handleMailboxChange(String arg0, PendingModifications arg1,
    			OperationContext arg2, int arg3) {
    		System.out.println("MyDeleteMailListener - In MailboxChange for account id: " + arg0);
    		System.out.println("MyDeleteMailListener - In MailboxChange : " + arg1.changedTypes);
    	}
    
    	@Override
    	public int registerForItemTypes() {
    		System.out.println("MyDeleteMailListener - In RegisterForItemTypes " + MailItem.typeToBitmask(MailItem.TYPE_CONVERSATION) + " and " + MailItem.typeToBitmask(MailItem.TYPE_MESSAGE));
    		return MailItem.typeToBitmask(MailItem.TYPE_CONVERSATION) | MailItem.typeToBitmask(MailItem.TYPE_MESSAGE);
    	}	
    }
    Thank You!

  2. #2
    vmahajan is offline Zimbra Employee
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    5

    Default

    PendingModifications has data structures "created", "modified", and "deleted". Also, for a modified item the reasons are enumerated in PendingModifications.Change.

    Note that this API is not officially supported and is subject to change in future releases.

  3. #3
    stalker is offline Special Member
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default

    Quote Originally Posted by vmahajan View Post
    PendingModifications has data structures "created", "modified", and "deleted". Also, for a modified item the reasons are enumerated in PendingModifications.Change.

    Note that this API is not officially supported and is subject to change in future releases.
    Alright, thank you. That is just I want. Is there any plan to extends these APIs? They are very much helpful and will make zimbra more flexible for developers.

  4. #4
    yutaka is offline Project Contributor
    Join Date
    Oct 2009
    Location
    Tokyo
    Posts
    113
    Rep Power
    5

    Default

    "notify" method in com.zimbra.cs.mailbox.alerts.CalItemReminderServic e class
    is good example for you, I guess.

  5. #5
    stalker is offline Special Member
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default

    Quote Originally Posted by yutaka View Post
    "notify" method in com.zimbra.cs.mailbox.alerts.CalItemReminderServic e class
    is good example for you, I guess.
    Thank you for reply. I'll take a look.

  6. #6
    sewerrat is offline Starter Member
    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    1

    Default

    Quote Originally Posted by vmahajan View Post
    PendingModifications has data structures "created", "modified", and "deleted". Also, for a modified item the reasons are enumerated in PendingModifications.Change.

    Note that this API is not officially supported and is subject to change in future releases.
    I'm having a problem with PendingModifications object. I can get the EmailItem from "createed" data, then get the list of Recipients's Cn(common name) by method MailItem.getSortRecipient(). But I want to get list of their email and I don't know how to do this. Can you show me??

  7. #7
    stalker is offline Special Member
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default

    Quote Originally Posted by sewerrat View Post
    I'm having a problem with PendingModifications object. I can get the EmailItem from "createed" data, then get the list of Recipients's Cn(common name) by method MailItem.getSortRecipient(). But I want to get list of their email and I don't know how to do this. Can you show me??
    Well, it seems you've to parse them and get it from the getRecipient method. Check the source code at https://github.com/Zimbra-Community/...x/Message.java

    I hope this helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Unable to receive e-mail after domain move
    By mrody in forum Administrators
    Replies: 9
    Last Post: 11-30-2010, 01:25 AM
  2. Remote IMAP clients unable to send email
    By AlanWilliamson in forum Administrators
    Replies: 6
    Last Post: 09-05-2007, 05:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •