The Cordova EmailComposer plugin provides the interface where user can send the message through email same as in the email composer. It manages the editing and sending the message. You can use this plugin to show the standard email view inside your mobile application and also modify the values of email fields i.e. subject, message, attachments, recipients. Here user can select the option to send or cancel the email message.
Adding the Plugin to your application:
run the following command to add this plugin:
cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git
Using the plugin:
After installing the plugin creates the object window.plugin.email with these methods:
1.email.isAvailable
2.email.open
Initializing Plugin:
The plugin and its methods can be used after deviceready event has been fired i.e.
document.addEventListener('deviceready', function () {
// window.plugin.email is now available
}, false);
Determine if the device can send emails:
cordova.plugins.email.isAvailable(
function (isAvailable) {
// alert('Service is not available') unless isAvailable;
}
);
Open a pre-filled email draft:
cordova.plugins.email.open({
to: Array, // email addresses for TO field
cc: Array, // email addresses for CC field
bcc: Array, // email addresses for BCC field
attachments: Array, // file paths or base64 data streams
subject: String, // subject of the email
body: String, // email body (for HTML, set isHtml to true)
isHtml: Boolean, // indicats if the body is HTML or plain text
}, callback, scope);
0 Comment(s)