我正在尝试使用名为Email Composer的Cordova插件让用户发送电子邮件。 Cordova Email Plugin
我正在生成一些HTML内容,并希望使用内容预填充电子邮件的正文。
我试过的代码:
function emailHtml(text) //variable to fill the body
{
cordova.plugins.email.isAvailable(
function (isAvailable) {
cordova.plugins.email.open({
to: 'your@email',
cc: 'second@mail',
bcc: [],
subject: 'Greetings',
body: text //the HTML content
});
}
);
}
但它还没有奏效。
在插件字段中使用变量的正确方法是什么?
感谢。
答案 0 :(得分:1)
你可以通过普通的Javascript实现它,不需要添加额外的插件并增加构建大小
let Link="mailto:someone@example.com?subject=Hello%20again";
window.open(Link, "_system");
您可以在链接中添加所需的所有参数。
答案 1 :(得分:0)
您需要使用参数isHtml: true
myHTML="<html> ......... </html>";
cordova.plugins.email.isAvailable(
function (isAvailable) {
cordova.plugins.email.open({
to: 'your@email',
cc: 'second@mail',
bcc: [],
subject: 'Greetings',
body: myHTML, //the HTML content
isHtml: true // indicats if the body is HTML or plain text
});
}
);