Code for adding attachment to compose window?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Code for adding attachment to compose window?

Burma-3
The following code for my extension works great.  It opens a new Compose
window with some of the headers filled in.  Can anybody tell me what
code to add to bring up a "browse for file" dialog to select
attachments?  Is nsIFilePicker the way to go?  Thanks much

var fields =
Components.classes["@mozilla.org/messengercompose/composefields;1"].createInstance(Components.interfaces.nsIMsgCompFields);
var params =
Components.classes["@mozilla.org/messengercompose/composeparams;1"].createInstance(Components.interfaces.nsIMsgComposeParams);

fields.to = "[hidden email]";
fields.from = "[hidden email]";
fields.subject = "test";

params.composeFields = fields;
params.format = Components.interfaces.nsIMsgCompFormat.PlainText;

msgComposeService.OpenComposeWindowWithParams (null, params);
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Code for adding attachment to compose window?

Magnus Melin
On 12.07.2009 03:50, Burma wrote:

> The following code for my extension works great.  It opens a new Compose
> window with some of the headers filled in. Can anybody tell me what code
> to add to bring up a "browse for file" dialog to select attachments? Is
> nsIFilePicker the way to go? Thanks much
>
> var fields =
> Components.classes["@mozilla.org/messengercompose/composefields;1"].createInstance(Components.interfaces.nsIMsgCompFields);
>
> var params =
> Components.classes["@mozilla.org/messengercompose/composeparams;1"].createInstance(Components.interfaces.nsIMsgComposeParams);
>
>
> fields.to = "[hidden email]";
> fields.from = "[hidden email]";
> fields.subject = "test";
>
> params.composeFields = fields;
> params.format = Components.interfaces.nsIMsgCompFormat.PlainText;
>
> msgComposeService.OpenComposeWindowWithParams (null, params);

See functino AttachFile() here:
http://mxr.mozilla.org/comm-central/source/mail/components/compose/content/MsgComposeCommands.js#2602

  -Magnus
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird