can not send mail with $cordovaEmailComposer
can any one please help
A more detailed explaination would be required for any of us to help. Doesnāt the composer open? Does it give any errors? Have you checked the console for any errors? What version of cordova are you using? Are you using Xwalk?
Thanks for the reply.
No the email composer does not open up.
Following my codes
var TestApp =angular.module(āTestAppā, [āionicā,āngStorageā,āngCordovaā]);
$ionicPlatform.ready(function(){
$cordovaEmailComposer.isAvailable().then(function() {
var email = {
to: EmailAddr,
subject: āCordova Iconsā,
body: āHow are you? Nice greetings from Leipzigā,
isHtml: true
};
$cordovaEmailComposer.open(email).then(function () {
alert('mailsend');
}),function () {
alert('error');
}
}, function () {
alert(āErrorā)
});
})
Please help
does $cordovaEmailComposer.isAvailable()
returns true
? If not, is there an email account configured on the device?
Thanks @ubunny for the information. I will retest it and confirm.
One problem is that ngCordova plugin does not work on ionic serve command when it opens up in a browser. I have to connect my android cell phone to do the testing.
I have changed my code
$ionicPlatform.ready(function() {
alert(ā2ā);
//document.addEventListener(ādevicereadyā, function () {
alert(ā3ā);
var email = {
to: EmailAddr,
subject: āCordova Iconsā,
body: āHow are you? Nice greetings from Leipzigā,
isHtml: true
};
$cordovaEmailComposer.open(email).then(function () {
alert(ā5ā);
alert(āmailsendā);
}), function () {
alert(āerrorā);
}
alert 3 is working but alert 5 never shows up
please use console.log and the android debug monitor. This is no way of testing Iām pretty sure you will find the problem there
Hi,
I am testing my app connecting my android cell phone as a device. Please suggest how to use log and android debug monitor.
I am working on web storm.
Thanks.
just use console.log instead of alert. If you have adb installed, there should also be a android-sdk/tools/monitor on your system. That way you can view logs in runtime. Also, other errors will be shown there
Iām not familiar with web storm but if youāre running via console/terminal you can use ionic run android --device -l -c
. You can also use android device monitor on IDEs such as Eclipse and Android Studio.
Finally the problem is solved.
To debug my code this time i use Visual Studio code and add a Cordova plugin in it
https://marketplace.visualstudio.com/items?itemName=vsmobile.cordova-tools
i remove my android platform and the all the mail sending libs.
Then run the following command again,
cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git
And then
ionic platform add android
I replace my code by the following,
$scope.SendMail=function(EmailAddr){
var email = {
to: EmailAddr,
subject: āTest Messageā,
body: āThis is a test messageā,
isHtml: true
};
$cordovaEmailComposer.isAvailable().then(function() {
$cordovaEmailComposer.open(email).then(null, function () {
// user cancelled email
});
}, function () {
// not available
});
};
And it works.
Thanks everyone for the help and suggestion.
Happy Codding.