如何在iPhone PhoneGap jQuery Mobile中将文件附加到邮件中 [英] How to attach a file to the mail in iPhone PhoneGap jQuery Mobile
问题描述
我已经使用jQuery Mobile在Phone Gap中实现了 iPhone应用程序。
作为我应用程序的一部分,我需要点击按钮'MAIL'发送电子邮件
为此我添加了 EmailComposer插件。
在www文件夹中添加了EmailComposer.js并且
添加了EmailComposer.H和.M文件在应用程序的Resources文件夹中。
我实现了如下代码
< script type =text / javascriptsrc =EmailComposer.js>< / script>
< script type =text / javascriptcharset =utf-8>
函数SendEmail(){
alert('XXXXX');
window.plugins.emailComposer.showEmailComposer(SubjectXXX,PlainTextBody ---,
recipientName,recipientName,ccRecipient,bccRecipient,false);
}
< / script>
< a href =#onclick =SendEmail(); return false; data-icon =arrow-rdata-iconpos =leftclass =ui-btn-left>发送< / a>
邮件编辑器视图显示一切正常。
现在我需要在此电子邮件中附加文件如何附加文件
任何人都可以指导我
提前预定。
我是这样做的:
var attachPath;
var attachFile = new Array();
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(fileSystem){
fileSystem.root.getDirectory(MyAppFolder,{
create:true
},
function(目录){
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);
},
函数(错误){
警报(error.code);
});
});
},函数(错误){
alert(甚至无法获取文件系统:+ error.code);
});
现在将attachFile传递给mailcomposer
window.plugins.emailComposer.showEmailComposerWithCallback(null,
估算,
正文,
[mail_id],
[],
[],
true,
attachFile
);
希望这可以帮助你!!!!!
I Have implemented an iPhone application in Phone Gap using jQuery Mobile.
As the part of my app i need to send an email by click on a Button 'MAIL'
For that i added EmailComposer plug in.
added EmailComposer.js in www folder and
added EmailComposer.H and .M file in Resources folder of application.
I implemented the code as follows
<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>
Mail composer view displays all is well.
Now I need to Atach a file to this email how to attach a file
Can any one guide me the way
tahnks in advance.
I did it this way:
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);
});
Now pass attachFile to mailcomposer
window.plugins.emailComposer.showEmailComposerWithCallback(null,
"Get an Estimate",
"Body",
["mail_id"],
[],
[],
true,
attachFile
);
Hope this helps you!!!!!
这篇关于如何在iPhone PhoneGap jQuery Mobile中将文件附加到邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!