Sending EMAIL in IONIC/angular generates an error Cannot read Property 'then' of Undefined, anyone know why?

Asked

Viewed 41 times

0

home.page.html

  <ion-icon name="Send" size="small"></ion-icon>
    <button ion-button icon-only (click) ="sendEmail()">
      Send Email
    </button>

home.pagets.

sendEmail() {
    this.emailComposer.isAvailable().then((available: boolean) =>{
      if(available) {

        let email = {
          to: '[email protected]',
          attachments: [
          ],
          subject: 'Started service order',
          body: 'Foi aberto a ordem',
          isHtml: true
        }

      // Send a text message using default options
      this.emailComposer.open(email);
      }     

    })  
  }

error:

PicturesPage.html:24 ERROR TypeError: Cannot read property 'then' of undefined
    at PicturesPage.push../src/app/pictures/pictures.page.ts.PicturesPage.sendEmail (pictures.page.ts:69)
    at Object.eval [as handleEvent] (PicturesPage.html:24)
    at handleEvent (core.js:23107)
    at callWithDebugContext (core.js:24177)
    at Object.debugHandleEvent [as handleEvent] (core.js:23904)
    at dispatchEvent (core.js:20556)
    at core.js:21003
    at HTMLButtonElement.<anonymous> (platform-browser.js:993)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:17290)

A simple email sending routine and do not know how to find solution, someone knows why this error happens?

1 answer

1


I am using this way and without errors. It allows me to choose which email application to send.

send() {
let email = {
  to: this.to,
  cc: [],
  bcc: [],
  attachment: [],
  subject: this.subject,
  body: this.body,
  isHtml: false,
  app: ""
}
this.emailComposer.open(email);

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.