Email Composer
The Email Composer plugin provides the ability to programmatically create and send emails from within an app.
#
InstallationIf you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.
Next, install the plugin:
- Capacitor
- Cordova
#
Using with AndroidX Projects (Android)This plugin relies on the legacy Android Support libraries and will not work in projects using the newer AndroidX libraries without using the jetifier tool to patch them.
To run it automatically when dependencies are installed, add "postinstall": "jetifier"
in the package.json
.
#
Index#
Classes#
Interfaces#
Classes#
EmailComposerusage:
You can also assign aliases to email apps
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
#
getClients▸ getClients(): Promise
<string
[]>
Returns an array of email clients installed on the device.
Returns: Promise
<string
[]>
Resolves if available, rejects if not available
#
hasAccount▸ hasAccount(): Promise
<any
>
Verifies if an email account is configured on the device.
Returns: Promise
<any
>
Resolves if available, rejects if not available
#
hasClient▸ hasClient(app: string
): Promise
<any
>
Verifies if a specific email client is installed on the device.
Parameters:
Name | Type |
---|---|
Optional app | string |
Returns: Promise
<any
>
Resolves if available, rejects if not available
#
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 | |
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#
EmailComposerOptionsEmailComposerOptions:
<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)