1

I just can't seem to get the e-mail sending working in Android. Probably something stupid but I can't find it:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/plain")
               .putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "jb@mail.anykey.co.il" })
               .putExtra(android.content.Intent.EXTRA_SUBJECT,"Exception in Yaniv!")
               .putExtra(android.content.Intent.EXTRA_TEXT,"test");
    ApplicationControllerBase.getMyApplicationContext().startActivity(Intent.createChooser(emailIntent,
             "Send mail...").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

I am not getting any error or exception on the startActivity command.

=======

Edit:

Seems that this is the same problem as this guy is having: Android: How to start an activity from an UncaughtExceptionHandler set in application

Community
  • 1
  • 1
theblitz
  • 6,683
  • 16
  • 60
  • 114
  • You don't need the flag `Intent.FLAG_ACTIVITY_NEW_TASK`, but other than that, it looks good to me. Are you getting an empty chooser, or is nothing showing up at all? – Paul Lammertsma Nov 16 '11 at 15:02

1 Answers1

0

setType should be plain/text

try with the following code

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("plain/text");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"webmaster@website.com"});
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "mySubject");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "myBodyText");
    startActivity(Intent.createChooser(emailIntent, "Send mail..."));
  • You sure it should be plain/text? I saw the opposite elsewhere. I nevertheless tried it and nothing happened. – theblitz Jul 07 '11 at 10:10