Reputation: 1
After my first question here, I am now looking for a way do the the same, but instead of opening an EML as a message, I want to open it as a draft.
Basically, I want to load a generated EML file into the compose window, so I can directly send it.
I already found some code, but I can't find the correct documentation on how to use it
var filePath = new FileUtils.File(getPath(params));
var uri = io.newFileURI(filePath);
var msgComposeService = Components.classes["@mozilla.org/messengercompose;1"].getService(Components.interfaces.nsIMsgComposeService);
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance(Components.interfaces.nsIMessenger);
var hdr = messenger.msgHdrFromURI(uri.spec);
var identity = getIdentityForHeader(hdr, Components.interfaces.nsIMsgCompType.Draft);
var msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].createInstance(Components.interfaces.nsIMsgWindow);
msgComposeService.OpenComposeWindow(null,null,uri,Components.interfaces.nsIMsgCompType.Draft,Components.interfaces.nsIMsgCompFormat.Default,identity,msgWindow);
Upvotes: 0
Views: 827
Reputation: 1739
I would suggest injecting the eml file into a local Drafts folder so as to get an nsIMsgDBHdr, and then calling the ComposeMessage
function with Ci.nsIMsgCompType.Draft, Ci.nsIMsgCompFormat.Default, yourMsgHdr.folder, yourMsgHdr'sURI
.
I think there are several StackOverflow answers on how to inject a given message into a folder.
Upvotes: 0