【问题标题】:How to attach a file to the mail in iPhone PhoneGap jQuery Mobile如何在 iPhone PhoneGap jQuery Mobile 中将文件附加到邮件
【发布时间】:2012-07-05 09:30:00
【问题描述】:

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

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

为此我添加了 EmailComposer plug in.

在 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>

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

现在我需要在此电子邮件中附加一个文件如何附加文件

谁能给我指路

提前联系。

【问题讨论】:

  • 您找到解决方案了吗?我很想听听。
  • 我一直在尝试在 iOS 中打开 mailcomposer 但无法打开,请给我您的示例代码。

标签: javascript iphone jquery-mobile cordova


【解决方案1】:

我是这样做的:

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

希望对你有帮助!!!!!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-22
    • 1970-01-01
    • 2012-04-13
    • 2011-10-22
    • 2017-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多