Hello Readers,
Cordova Email composer plugin allows you to send any HTML content to any email account. It provides standard email view into your application and user can edit or delete the content as per requirement.
This plugin supports iOS, Android, Windows platforms.
To use this plugin we need to install it first through CLI :
cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git
This plugin creates cordova.plugins.email object which invokes following methods:
- email.isAvailable: Determines if device capable to send the message. Email service works on only those devices which are able to send emails.
Note: You need to configure the email account to send emails.
- email.open: This method works when you want to open pre-filled email in draft or we can use email.openDraft method for the same.
Example:
cordova.plugins.email.open({
to: 'abc@gmail.com',
cc: 'xyz@gmail.com',
bcc: ['ss@gmail.com', 'mm@gmail.com'],
subject: 'Greetings',
body: 'How are you?'
});
- Send an email with HTML encoded body: To send an email with HTML encoded we need to set isHTML property.
cordova.plugins.email.open({
to: 'abc@gmail.com',
subject: 'Welcome',
body: '<h1>Hi how are you?</h1>',
isHtml: true
});
- Adding attachment: We can add attachment to the email from device storage or www folder of project. We need to set attachments property to send email along with attachment.
cordova.plugins.email.open({
subject: 'Attachment',
attachments: 'abc.png'
});
Here is a basic overview on email composer plugin. For more information click here.
Hope this will help you:)
0 Comment(s)