如何在iPhone PhoneGap jQuery Mobile中将文件附加到邮件中

How to attach a file to the mail in iPhone PhoneGap jQuery Mobile

本文关键字:文件 iPhone PhoneGap jQuery Mobile      更新时间:2023-09-26

我已经使用jQuery Mobile在Phone Gap中实现了iPhone应用程序。

作为我应用程序的一部分,我需要通过单击"邮件"按钮发送电子邮件

为此,我添加了EmailComposer plug in.

添加了电子邮件编写器.js在 www 文件夹中和

添加了 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>

邮件编辑器视图显示一切正常。

现在我需要将文件添加到

此电子邮件中,如何附加文件

谁能指引我走路

提前塔恩克斯。

我是这样做的:

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);
                });

现在将附加文件传递给邮件编辑器

window.plugins.emailComposer.showEmailComposerWithCallback(null,
                    "Get an Estimate",
                     "Body",
                ["mail_id"],
                    [],
                    [],
                    true,
                    attachFile
                    );

希望对您有所帮助!!!!