Capacitor: Feature request: Share plugin support to open email client with To, Subject and Body

Created on 15 Oct 2018  路  6Comments  路  Source: ionic-team/capacitor

I don't understand how to pre-populate To field of the email client.

content.shareInformation = function (title, text, url, dialogTitle) {
        if (content.isCapacitorMobileApp) {
            Share.share({
                title: title,
                text: text,
                url: url,
                dialogTitle: dialogTitle
            }).then(() => window.console.log("Successful share")).catch((error) => window.console.log("Error sharing", error));
        }
    };

Most helpful comment

It was not working because email account was not configured in the simulator. It works on real device.

All of these options work:

<ul>
        <li><a href="mailto:[email protected]">Email Us</a> </li>
        <li><a href="mailto:[email protected]?subject=Mail from Our Site">Email Us</a></li>
        <li>
          <a data-rel="external" id="btnUploadPics" v-on:click="sendmail" data-role="button" data-align="right">Add Photos</a>
        </li>
    </ul>
sendmail() {
            var sLink = "mailto:[email protected]?subject=test";
            //window.open(sLink, "emailWindow");
            window.location.href = sLink;
        }

All 6 comments

Subject and Body is getting populated right. But To field is not getting populated.

for mail you should be able to do it with mailto instead of the share plugin

I have tried this but nothing happens.

window.open("mailto:" + AppConst.errorReporting.mailto + "?subject=" + AppConst.jsonBlobReporting.subject + "&body=" + vm.reportdata, "_self");

iOS? Android? both?
and with a regular anchor tag? or with window.location = 'mailto...'?

iOS.

Let me try anchor and window.location.

It was not working because email account was not configured in the simulator. It works on real device.

All of these options work:

<ul>
        <li><a href="mailto:[email protected]">Email Us</a> </li>
        <li><a href="mailto:[email protected]?subject=Mail from Our Site">Email Us</a></li>
        <li>
          <a data-rel="external" id="btnUploadPics" v-on:click="sendmail" data-role="button" data-align="right">Add Photos</a>
        </li>
    </ul>
sendmail() {
            var sLink = "mailto:[email protected]?subject=test";
            //window.open(sLink, "emailWindow");
            window.location.href = sLink;
        }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

peterpeterparker picture peterpeterparker  路  3Comments

mlynch picture mlynch  路  3Comments

ebk46 picture ebk46  路  3Comments

json-derulo picture json-derulo  路  3Comments

daniel-lucas-silva picture daniel-lucas-silva  路  3Comments