The Deep End

go to! email!

Thursday, February 24, 2005

Thunderbird Extensions: Opening a Compose Window

Previous posts have made vague and mysterious allusions to "opening a compose window" and to clear that up, here's how:

There are actually a multitude of ways to open a compose window, but most of them will have nsIMsgComposeParams and nsIMsgComposeService.

The way I found it done was in the DictionarySearch extension (this is a little bit different from his version but not much):

function composeMessageWithText(subject,text,type,format){
var msgComposeType = Components.interfaces.nsIMsgCompType;
var msgComposFormat = Components.interfaces.nsIMsgCompFormat;
var msgComposeService = Components.classes[';1'].getService();
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);

gAccountManager = Components.classes[';1'].

var params = Components.classes[';1'].
if (params)
params.type = msgComposeType.Template;
params.format = format;
var composeFields = Components.classes[';1'].
if (composeFields)
{ = ""
text = trimAll(text);
composeFields.body = text;
composeFields.subject = subject;

params.composeFields = composeFields;

msgComposeService.OpenComposeWindowWithParams(null, params);

The other ways are all through msgComposeService; for the nsIMsgWindow parameter, type msgWindow. This works because...msgWindow is always the right menu? At any rate, it always works. Which is nice, even if it is complicated.


Post a Comment

<< Home