Thunderbird Extension Development
Overlay Reference:
chrome://messenger/content/messenger.xul- statusbar
chrome://messenger/content/mailWindowOverlay.xul- Toolbar Menu (taskPopup), Message Context Menu (threadPaneContext)
chrome://messenger/content/msgHdrViewOverlay.xul- Attachment Context Menu (attachmentListContext)
Accessing Attachments
var attachmentList = document.getElementById( 'attachmentList' ) // returns attachment list
var selectedAttachments = attachmentList.selectedItems; //Get selected attachments
Getting Message Information
var MessageUri = GetFirstSelectedMessage(); // Get Message URI
/* Get message body as it appears in preview window */
body = document.getElementById("messagepane").contentDocument.body.innerHTML;
Accessing Limited Message Header information
var msg = messenger.messageServiceFromURI(uri); // get message object
var hdr = msg.messageURIToMsgHdr(uri); // get header object
var subject = hdr.mime2DecodedSubject; // get Subject
var from = hdr.mime2DecodedAuthor; // get From
var to = hdr.mime2DecodedRecipients; // get To
var msgdate = new Date( hdr.date/1000); // turn epoch into date
var messageid = hdr.messageId; // get message ID
Downloading Attachments
This piece of code will take all selected attachments and download them to C:\ with their original filenames.
attachments = this.getSelectedAttachments();
for( i=0;i
var attachment = attachments[i];
/* Create a file interface object */
var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
var fullfilepath = 'C:/test/' + attachment.displayName;
file.initWithPath(fullfilepath);
if(!file.exists()) {
file.create(0x00,0644);
}
messenger.saveAttachmentToFile( file, attachment.url, attachment.uri, attachment.contentType, null );
}