Search code examples
ionic2screenshotsendmail

Take screenshot of page and send it via email IONIC 2


I am new to app dev and I am building a cross platform app with Ionic 2. I am having difficulties in implementing a function to take a screenshot of the page and send it attached to an email.

Can someone show me how to do that? Is it possible to send the email within Ionic without using the Mail app? How?


Solution

  • You can use Screenshot Plugin together with the SocialSharing Plugin to accomplish your task.

    Your code will be similar to the following one:

    Screenshot.URI(80)
            .then((res) => {
                SocialSharing.shareViaEmail(message, subject, to, cc, bcc, res.URI //file)
                  .then(() => { alert('success') },
                    () => { alert('failed'); });
              },
              () => {alert('failed');});
    

    Please ignore any typo.