如何使用cordova在android中发送电子邮件。自从两天以来我一直在努力,但我收到的错误就像电子邮件插件不可用。一直在尝试使用此代码,但无法获得我想要的结果。不知道问题是......
<!DOCTYPE html>
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
var options = new ContactFindOptions();
navigator.contacts.pickContact(onSuccess, function(contact){
console.log('The following contact has been selected:' + JSON.stringify(contact));
},function(err){
console.log('Error: ' + err);
});
}
document.addEventListener("deviceready", draftEmail, false);
function draftEmail(subject, message) {
if (!cordova.plugin){
//non-mobile - plugins are not present.
alert("Email plugin is not available");
return;
}
if (!isAvailable){
//mobile, but no email installed
alert("Email is not available")
return;
}
cordova.plugins.email.addAlias('gmail', 'com.google.android.gm');
cordova.plugins.email.open({
app: 'gmail',
to: 'abcd@gmail.com',
subject: 'Sent from Gmail',
body: 'How are you?',
isHtml: true
})
}
</script>
</head>
<body>
</body>
</html>
答案 0 :(得分:0)
在draftEmail中,您正在检查cordova.plugin但不检查cordova.plugins,因此您收到错误警告。