title: Accessing the Thunderbird message when closing a message tab / window
body: <p>We have developed a Thunderbird (11) plugin that allows us to save the content of a message to disk. Now we are extending this extension to allow automatic processing of a message when you close it. We run into a number of issues:</p>
  
  <p>We cannot find a way to hook into a 'close tab' event. We are also having trouble getting the Message URI of the currently open tabs (we are trying catching click and keyboard events now). This information does not appear to be available in the DOM of the tab container.</p>
  
  <p>Is there a way to detect closing of a mail message tab or window in a generic way, together with retrieving the URI of the closed mail message for further processing?</p>
  
  <p>We have looked at the documentation of the tab container, the <code>NsIWindowMediator</code>, tried various event listeners, but no luck so far.</p>
  
  <p>Edit: We are getting some results using the most recently closed tabs list. Not a very elegant solution but at least we have a reference to the tab. Now we only have to get the URI to the message that was contained inside the tab.</p>