Then, within the Zimlet's Javascript file, we need to override 'doDrop' function.

com_zimbra_coloredemails.prototype.doDrop =
function(zmObject) {
};

The email dropped(zmObject) can be either a conversation or a single email. This zmObject internally has an object called 'srcObj' (source-object) and contains the real or actual Zimbra Object that was dropped. Once we get access to this, we can access all the properties and even functions.

Get email body

Get list of attachments

Get list of Tags

var tagsArray = msgObj.tags;//returns array containing all the tags tagged to this message

Get List of all Emails or Conversations

The below code works when a user clicks on a panelItem when in mail app.
PS:
- You will have to make sure you are in mail app.
- Depending on the view(Message or Conversation), the array will contain corresponding("ZmMailMsg" or "ZmConv") items

AddressBook

Notebook

Tasks

Briefcase

Toolbar

For convenience purposes we can add a Zimlet button on the top toolbar itself. This section provides few examples on how to deal handle this aspect.
First, we need to get access to the toolbar-itself in order to access toolbar buttons. In order to do this we need to know how things are connected. In general, 'an application' has at least one 'View'-object (usually multiple-views). And each of these 'Views' have individual 'Toolbars'-objects. i.e. if we need to add a button or change a button we need to add it to all these (possibly) multiple toolbars.
For example:
Mail has 4 views: Conversation view, Conversation List View, Message View & Message List View. And each one of these views has a toolbar object (i.e. total 4 toolbars). So, if we want to add a button or update a button, we need to apply it to all those views.

How to add a Zimlet toolbar button

How to override an *existing* toolbar button in mail app (to do something else)

The below code snippet allows replacing (Junk/Not Junk)button's(ZmId.OP_SPAM) functionality with a custom functionality(newSelectionListener).
PS: This is only for mail app.

How to add additional functionality to an *existing* toolbar button

The below code snippet allows adding more functionailty to (Junk/Not Junk)aka SPAM button's existing functionality. i.e When a user clicks on Junk button, it will mark the mail as Junk AND then calls the function newSelectionListener .

PS: Please go through the section 'How to override a toolbar button in mail app (to do something else)' for the complete code. And simply comment the btn.removeSelectionListeners() in the function replaceMailToolbarBtnListener.