I've been searching high and low for an answer to this question. I've downloaded and successfully installed the EmailComposer plugin for PhoneGap. I'm able to click on my "Email" button the email field pops up no problem there. The issue is, i'm trying to pre-populate the "To:" field and the "Subject" field. I've searched various posts (mainly on StackOverflow) and i've seen some similar posts, but nothing with this exact same issue or a real solution:
posts I've tried: PhoneGap Email Composer Plugin How to send email using mail composer plugin in iphone using phone gap jQuery mobile
The closest I was able to find has been here: https://groups.google.com/forum/#!searchin/phonegap/EmailComposer/phonegap/ItUj30UZnig/XTaBK7B8ahsJ
But i haven't had any luck with the solution there.
As mentioned above. All i'm trying to do is pre-populate the "To:" and "Subject:" field. The included EmailComposer.js doc looks like this:
// window.plugins.emailComposer
function EmailComposer() {
this.resultCallback = null; // Function
}
EmailComposer.ComposeResultType = {
Cancelled:0,
Saved:1,
Sent:2,
Failed:3,
NotSent:4
}
// showEmailComposer : all args optional
EmailComposer.prototype.showEmailComposer = function(subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML) {
var args = {};
if(toRecipients)
args.toRecipients = toRecipients;
if(ccRecipients)
args.ccRecipients = ccRecipients;
if(bccRecipients)
args.bccRecipients = bccRecipients;
if(subject)
args.subject = subject;
if(body)
args.body = body;
if(bIsHTML)
args.bIsHTML = bIsHTML;
cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
}
// this will be forever known as the orch-func -jm
EmailComposer.prototype.showEmailComposerWithCB = function(cbFunction,subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML) {
alert("email showEmailComposerWithCB?");
this.resultCallback = cbFunction;
this.showEmailComposer.apply(this, [subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML]);
}
EmailComposer.prototype._didFinishWithResult = function(res) {
this.resultCallback(res);
}
cordova.addConstructor(
function() {
if(!window.plugins) {
window.plugins = {};
}
// shim to work in 1.5 and 1.6
if (!window.Cordova) {
window.Cordova = cordova;
};
//window.plugins.emailComposer.showEmailComposer(subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML)
window.plugins.emailComposer = new EmailComposer();
}
);
The actual line that starts with:
EmailComposer.prototype.showEmailComposer
Is never actually fired. On the public facing side, I have this (it's valid HTML but i removed some tags for posting purposes:
<a onclick="cordova.exec(null, null, 'EmailComposer', 'showEmailComposer', [args]);">Send Email</a>
I then have:
app.initialize();
var args;
Which happens when the page first loads.
Any ideas on what I'm doing wrong here?