Email Composer

v0.9.2

Contents

Installation

In order to use Ionic Enterprise Edition plugins you should make sure you're using the Ionic Enterprise Cordova CLI as the regular version can have issues with scoped plugins.

npm uninstall -g cordovanpm install -g @ionic-enterprise/cordova

Once you've installed the Ionic Enterprise Cordova CLI you can install the plugin.

ionic enterprise register --key=YOURPRODUCTKEYionic cordova plugin add @ionic-enterprise/email-composer

Index

Classes

Interfaces


Classes

EmailComposer

EmailComposer:

name: Email Composer

description:

usage:

import { EmailComposer } from '@ionic-enterprise/email-composer/ngx'; constructor(private emailComposer: EmailComposer) { } ... this.emailComposer.isAvailable().then((available: boolean) =>{ if(available) { //Now we know we can send } }); let email = { to: 'max@mustermann.de', cc: 'erika@mustermann.de', bcc: ['john@doe.com', 'jane@doe.com'], attachments: [ 'file://img/logo.png', 'res://icon.png', 'base64:icon.png//iVBORw0KGgoAAAANSUhEUg...', 'file://README.pdf' ], subject: 'Cordova Icons', body: 'How are you? Nice greetings from Leipzig', isHtml: true } // Send a text message using default options this.emailComposer.open(email);

You can also assign aliases to email apps

// add alias this.email.addAlias('gmail', 'com.google.android.gm'); // then use alias when sending email this.email.open({ app: 'gmail', ... });

interfaces: EmailComposerOptions

addAlias

addAlias(alias: string, packageName: string): void

Adds a new mail app alias.

Parameters:

Name Type Description
alias string The alias name
packageName string The package name

Returns: void


hasPermission

hasPermission(): Promise<boolean>

Checks if the app has a permission to access email accounts information

Returns: Promise<boolean> returns a promise that resolves with a boolean that indicates if the permission was granted


isAvailable

isAvailable(app?: string): Promise<any>

Verifies if sending emails is supported on the device.

Parameters:

Name Type
Optional app string

Returns: Promise<any> Resolves if available, rejects if not available


open

open(options: *EmailComposerOptions, scope?: *any): Promise<any>

Displays the email composer pre-filled with data.

Parameters:

Name Type Description
options EmailComposerOptions Email
Optional scope any

Returns: Promise<any> Resolves promise when the EmailComposer has been opened


requestPermission

requestPermission(): Promise<boolean>

Request permission to access email accounts information

Returns: Promise<boolean> returns a promise that resolves with a boolean that indicates if the permission was granted



Interfaces

EmailComposerOptions

EmailComposerOptions:

<Optional> app

● app: string

App to send the email with


<Optional> attachments

● attachments: string[]

File paths or base64 data streams


<Optional> bcc

● bcc: string | string[]

Email address(es) for BCC field


<Optional> body

● body: string

Email body (for HTML, set isHtml to true)


<Optional> cc

● cc: string | string[]

Email address(es) for CC field


<Optional> isHtml

● isHtml: boolean

Indicates if the body is HTML or plain text


<Optional> subject

● subject: string

Subject of the email


<Optional> to

● to: string | string[]

Email address(es) for To field


<Optional> type

● type: string

Content type of the email (Android only)



Other Versions