cfcorp
cfcorp

Reputation: 99

Issue with Phonegap email plugin

I am building a PhoneGap cross platform app and I am trying to use the cordova email composer plugin. I am building the apps using the online Adobe phonegap builder. Im using some sample code, shown below, which when I build and run the app tells me that "is email mobile available? no" This message is fired from the sample code which runs when i press a button, at the minute I want to just see the email app open up and populate with the predefined message. The app build with no errors on PhoneGap build as ive included the reference to the plugin in my config.xml. Is there something else I am missing? Thanks Regards

{

document.addEventListener('deviceready', function () {
    cordova.plugins.email.isAvailable(
        function (isAvailable) {
            alert("is email mobile available? " + (isAvailable ? "Yes" : "No"));
            if(isAvailable){
             window.plugin.email.open({
                 to:      '[email protected]',
                 subject: 'Greetings',
                 body:    'How are you? Nice greetings from Leipzig'
             }, callback, scope);
           }
        }
    );
}, false);

function callback(){
    console.log("callback function");
}

function scope(){
    console.log("scope function");

}

Upvotes: 1

Views: 39

Answers (1)

Ramprasath Selvam
Ramprasath Selvam

Reputation: 4428

Using cordova-plugin-email.

Function SentEmail(){     
  window.plugin.email.isServiceAvailable(function (isAvailable) {
                if(isAvailable)
                {
                  window.plugin.email.open({
                                to:          [Your to email address],
                                cc:          [''],
                                bcc:         [''],
                                subject:     "subject,
                                body:        "<br/> your body content",
                                isHtml:      true
                       });
                 }
                 else
                 Alert('Please add an email account on this device to make email service available.');
}

Upvotes: 1

Related Questions