我已经使用 jQuery Mobile 在 Phone Gap 中实现了一个 iPhone 应用程序。
作为我的应用程序的一部分,我需要通过点击“MAIL”按钮发送电子邮件
为此,我添加了 EmailComposer 插件。
在 www 文件夹中添加了 EmailComposer.js
在应用程序的 Resources 文件夹中添加了 EmailComposer.H 和 .M 文件。
我实现的代码如下
<script type="text/javascript" src="EmailComposer.js"></script>
<script type="text/javascript" charset="utf-8">
function SendEmail() {
alert('XXXXX');
window.plugins.emailComposer.showEmailComposer("SubjectXXX","PlainTextBody---",
"recipientName,recipientName", "ccRecipient", "bccRecipient",false);
}
</script>
<a href="#" onclick="SendEmail(); return false;" data-icon="arrow-r" data-iconpos="left" class="ui-btn-left" >Send</a>
邮件编辑器 View 显示一切正常。
现在我需要将文件附加到此电子邮件如何附加文件
谁能给我指路
提前致谢。
最佳答案
我是这样做的:
var attachPath;
var attachFile= new Array();
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory("MyAppFolder", {
create: true
},
function(directory) {
console.log("Final 63" + directory.fullPath);
attachPaths = directory.fullPath;
var attachPath=attachPaths.slice(7,attachPaths.length);
var directoryReader = directory.createReader();
directoryReader.readEntries(function(entries) {
var i;
for (i=0; i<entries.length; i++) {
console.log(entries[i].name);
attachFile[i] =attachPath + "/" + entries[i].name;
}
console.log(attachFile);
},
function (error) {
alert(error.code);
});
});
}, function(error) {
alert("can't even get the file system: " + error.code);
});
现在将 attachFile 传递给 mailcomposer
window.plugins.emailComposer.showEmailComposerWithCallback(null,
"Get an Estimate",
"Body",
["mail_id"],
[],
[],
true,
attachFile
);
希望这对你有帮助!!!!!!
关于javascript - 如何将文件附加到 iPhone PhoneGap jQuery Mobile 中的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11341503/