-1

I am trying to use mailto link in my app but when clicking that link, I am getting a screen saying

"Webpage not available and some error", although email application opens properly but I want to bypass that background error page.

Please note that I am using following code inside the button click:

window.open('mailto:alok1141@gmail.com?subject=Feedback: Competitive Aptitude');

Please suggest any way to avoid this background page. Image with background error screen

Ghasem
  • 14,455
  • 21
  • 138
  • 171
Alok
  • 9
  • 5
  • The best way to send an email is asking for a client, because you don't know what email client is using the customer – M. Mariscal Mar 31 '16 at 14:05
  • Thanks Buddy, You got the right idea but I guess there is not any attribute available to select the specific email client. Can you suggest me any alternative. Thanks in advance. – Alok Mar 31 '16 at 14:20
  • Ok I think that you need this code for send an email by android email system app (default): http://stackoverflow.com/questions/20355870/explicit-intent-for-android-default-email-client, hope to be helpful! look at **setClassName(...)** – M. Mariscal Mar 31 '16 at 17:05

4 Answers4

0

My best guess is that you need to use a link <a href="mailto:..."> instead of a button or maybe use window.location=... in the onClick so that the browser can present the popup directly.

Now you tell the browser to open a window with the mailto url so only after the window has been opened it will check the url and present the popup.

0

There's two kind of format "mailto:" or "message/rfc822" MIME type. You have to add it on Intent with setType() If no app supports both, then it will shows the default chooser.

M. Mariscal
  • 1,226
  • 3
  • 17
  • 46
0

Have you tried setting the target to _system? It could be that your app is attempting to handle the link itself and failing. By setting the target to _system, you are asking the OS to open it for you.

window.open('mailto:alok1141@gmail.com?subject=Feedback: Competitive Aptitude', '_system');

You will also need the inappbrowser plugin. This plugin ensures that adding _system actually works. I believe on Android you may not need this, but you definitely will for iOS.

cordova plugin add cordova-plugin-inappbrowser
stransen
  • 25
  • 1
  • Thanks, I found the solution. Actually when you run the application in phonegap app it will not open href="mailto: xyz@email.com" thats why I had to use window.open, but once you will build the app even href="mailto: xyz@email.com" will work and best thing is it will directly open the app and no background error page wil appear – Alok Apr 05 '16 at 05:24
0

Thanks, I found the solution. Actually when you run the application in phonegap app it will not open href="mailto: xyz@email.com" thats why I had to use window.open,

but once you will build the app even href="mailto: xyz@email.com" will work and best thing is it will directly open the app and no background error page will appear.

Alok
  • 9
  • 5