1

I have a Forgot Password TextView on which I performed onPressed() event and want the application to send Email to a specific preset Email Id. My code is as follows but it doesn't send Email to the specified address.

    String value = "Hello Sir/Madam," + "\n" + "\t" + "Your email id and password are:" + "\n"  + passw;
    String[] address = {"nilaysheth@yahoo.co.in"};
    String subject = "Forgot Password";
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, address);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, value);
    startActivity(Intent.createChooser(emailIntent, "Send Email.."));
Name is Nilay
  • 2,743
  • 4
  • 35
  • 77

1 Answers1

2

Take a look here, it's already been asked on this forum:

Community
  • 1
  • 1
Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
  • Sorry for asking it so late...but is it possible that it might not work on Emulator but work efficiently on Device ?? – Name is Nilay Jul 06 '12 at 07:08
  • 1
    If you don't have multiple apps on the emulator that would take in an email intent, then you won't get a chooser, as the user only has one option anyway. So if you only have the regular email client and not gmail on the emulator, and no other app that would handle the ACTION_SEND intent, then that might explain why you don't see it on the emulator. – Mathias Conradt Jul 06 '12 at 08:50
  • No..actually I am getting a screen showing "No application can perform this action." – Name is Nilay Jul 06 '12 at 09:51
  • But there's an email client installed on the emulator? Then I don't know, haven't tried on emulator myself. Seems no suitable app is on the emulator to handle it. – Mathias Conradt Jul 06 '12 at 10:11