EmailComposer plugin

I am trying to use the EmailComposer plugin:

I installed it with:
cordova plugin add

But when I try to use it:

var ec = new EmailComposer();

I get ‘Uncaught ReferenceError: EmailComposer is not defined’

What am I missing here?



I believe you need to run “cordova build” to actually generate the plugin code in the relevant platform directory.

I already did that but I still get the same error

Ah EmailComposer isn’t what you want to reference - use Example:{
                             to:      [''],
                             cc:      [''],
                             bcc:     ['', ''],
                             subject: 'Greetings',
                             body:    'How are you? Nice greetings from Leipzig'
1 Like

That works. Thanks a lot. It still puzzles me why EmailComposer is not recognized as the email_composer.js that exists under plugins/ directory defines that.

That’s because in www/cordova_plugins.js it’s set to be inserted into the window object as (see the clobbers properties in that js file). Notice in email_composer.js that EmailComposer is only defined/declared in the scope of a cordova.define & not the global window scope.

Anyone know how to use the callback function about emailcomposer?

The open method supports an additional callback to get informed when the view has been dismissed.
    to:          Array, // email addresses for TO field
    cc:          Array, // email addresses for CC field
    bcc:         Array, // email addresses for BCC field
    attachments: Array, // paths to the files you want to attach or base64 encoded data streams
    subject:    String, // subject of the email
    body:       String, // email body (could be HTML code, in this case set isHtml to true)
    isHtml:    Boolean, // indicats if the body is HTML or plain text
 }, function () {
    // Callback
    console.log('email view dismissed');
}, scope);

I tried it but it not work!
This is my code :{
//to do get email contact
subject: “Display at image”,
attachments:[$scope.picData]}, function () {
console.log(‘email view dismissed’);
}, $scope);

Try this:
        subject: "Display at image",
    function () {
        console.log('email view dismissed');

Tried, same result…{
//to do get email contact
subject: “Display at image”,
attachments:[$scope.picData]}, function () {
console.log(‘email view dismissed’);
}, this);

It does work for me.

  • Did you install the plugin?
  • Does the compose window even open?
  • Do you wait until Cordova is ready ($ionicPlatform.ready)?
  • Did you add $ionicPlatform to your controller?
  • Maybe there’s a problem with your variables $scope.sendEmailname and $scope.picData`

Try something single which works a 100 %:

// Wait until Cordova is ready
$ionicPlatform.ready(function() {
            subject: 'Display at image'
        function () {
            alert('email view dismissed');

I have also been facing the problems related to callback.I have been using the following lines of code to call the email composer in my windows phone 8 app{
    to:      '',
    cc:      '',
    bcc:     '',
    subject: emailShare.message,
    body:    emailShare.description

the callback function gets fired the moment when the above function is called.What i want is i want to fire the callback method when the mail has been sent.

What am i missing please help

Hi to all. I struggle to make it work so far.

I am using phonegap developer app to test it.

For testing purposes i do this;

to show an empty email composer but the app doesn’t do anything.

I an using the latest version (0.8.2dev).

my installation process is this

cordova plugin add

and then i put the snipet from above in my controller.

Do i need to place something in the confiig.xml or something??

Thank you

Did you try to see whether email service is available?
                function (isAvailable) {
                   console.log("it is available);

Also, I would try to open the email composer with some options:{
                 to:      [$],
                 subject: $scope.subject,
                 body:    $scope.body,
                 isHtml: true

I know I am not giving you pearls here but it’s worth a shot.

As the creator of the app says:

This interface does not provide a way for you to verify whether emails were actually sent.


If you try to simulate on chrome I think that not work fine,because not found plugin, Although I have the plugin installed and I have verified the path…