Phonegap - 从应用程序发送邮件

时间:2013-04-25 11:32:01

标签: email cordova plugins

我需要在我的应用上添加一个按钮,将建议邮件发送到我的Gmail。

我尝试了一些方法,但没有一种方法有效。

我正在尝试,像这样:

<section data-role="page" id="home">
        <article data-role="content" style="position: fixed;text-align: center;width: 100%;height: 100%;margin:0;padding:0;overflow: hidden;" >
            <!--<a id="go" href="#view-feed-custom"> <img style="max-width: 100%;" src="img/portada.jpg" alt="Logo"> </a>-->

            <script>
            var args = {
                subject: 'Hi there',
                body: 'message to suggest you',
                toRecipients: 'reciver@gmail.com'
            };
            cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
            </script>

            <a href="#" onclick="cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);">Enviar Sugerencia 2</a> 

        </article>

    </section>

3 个答案:

答案 0 :(得分:1)

我现在尝试你给我看的两种方法......

<body onload="init()">

        <!-- START -->
        <section data-role="page" id="home">
            <article data-role="content" style="position: fixed;text-align: center;width: 100%;height: 100%;margin:0;padding:0;overflow: hidden;" >
                <a id="go" href="#view-feed-custom"> <img style="max-width: 100%;" src="img/portada.jpg" alt="Logo"> </a>
            </article>

            <script>
            function send(){
                var args = {
                    subject: 'Hi there',
                    body: 'message to suggest you',
                    toRecipients: 'miemail@gmail.com'
                };
            cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
           }
            </script>
            <button onclick='send();'>Send Mail onClick</button>
            <button href="mailto:email@email.com?cc=email2@email.com&bcc=email3@email.com&subject=The subject of the email&body=The body of the email">Enviar Correo href</button>

        </section>

但没有跑步/工作......

很多人帮帮我!

答案 1 :(得分:0)

你试过了吗?

<a href="mailto:email@email.com">email</a>

你可以添加更多这样的参数:

<a href="mailto:email@email.com?cc=email2@email.com&bcc=email3@email.com&subject=The subject of the email&body=The body of the email">Send mail with cc, bcc, subject and body</a>

此锚点将调用设备的本机邮箱。

答案 2 :(得分:0)

而不是使用<a>代码使用<button>代码,并在代码属性中提供'onClick=aFunction();'

aFunction()可以定义为 -

function aFunction(){
            var args = {
                    subject: 'Hi there',
                    body: 'message to suggest you',
                    toRecipients: 'reciver@gmail.com'
                };
            cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
            }

此外,请确保您已在EmailComposer.js文件夹和www(假设您在iOS上)和.m文件中添加.h plugins folder }}