How can I get the contents of an attachment in a Mozilla Thunderbird extension?

StackOverflow https://stackoverflow.com/questions/4393117

  •  10-10-2019
  •  | 
  •  

Question

I'm building an extension to Mozilla Thunderbird that does some translation of messages. I'd like to add a translate attachment feature, although I'm having a bit of trouble getting to the contents of each attachment. At the moment, I'm hooking into the attachmentListContext popup, and I have some code that gathers the relevant attachment URI and URLs. How can access the binary data of each relevant attachment?

Current code to get selected attachments:

handleAttachmentTranslate : function() {
  // see code in msgHeaderViewOverlay.js in Thunderbird source
  var attachmentList = document.getElementById('attachmentList');
  var selectedAttachments = new Array();
  for (var i in attachmentList.selectedItems) {
    var attachment = attachmentList.selectedItems[i].attachment; 
    // we can now access attachment.url or attachment.uri, etc
    selectedAttachments.push(attachment.url);
    // or (ideally)
    // alert(this.translate(getData(attachment.url)))
    // but what is getData()?
  }
},
Was it helpful?

Solution

FiltaQuilla addon does have the ability to save attachments etc. It may contain some code that's relevant.

Update Apr 25 2011: The page posted by speedball2001 has been modified between Mar 25 and Mar 31. Now it has a complete example. Check that out. It also points to a real extension that does exactly the attachment manipulation. This looks to be a promising answer.

The thought now is to hook up this new demo code to FiltaQuilla if necessary.

OTHER TIPS

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top