Creating a message for sending later

// Set the data of the message
let compFields = Components.classes["@mozilla.org/messengercompose/composefields;1"].createInstance(Components.interfaces.nsIMsgCompFields);
compFields.from = "from@example.com";
compFields.to = "to@example.com";
compFields.subject = "test";
compFields.body = "message body\r\n";
let msgComposeParams = Components.classes["@mozilla.org/messengercompose/composeparams;1"].createInstance(Components.interfaces.nsIMsgComposeParams);
msgComposeParams.composeFields = compFields;

let gMsgCompose = Components.classes["@mozilla.org/messengercompose/compose;1"].createInstance(Components.interfaces.nsIMsgCompose);
Components.utils.import("resource:///modules/mailServices.js");
let am = MailServices.accounts;
gMsgCompose.initialize(msgComposeParams);
gMsgCompose.SendMsg(Components.interfaces.nsIMsgCompDeliverMode.Later,
                    am.defaultAccount.defaultIdentity, // identity
                    am.defaultAccount, // account
                    null, // message window
                    null); // nsIMsgProgress

Document Tags and Contributors

 Contributors to this page: Aryx
 Last updated by: Aryx,