2

Im trying to send an email in Android on 2.1 and I have two problems.

1) firstly, to To field does not populate

2) the type message/rfc822 creates an error: "no applications can perform this action"

    Intent msg = new Intent(Intent.ACTION_SEND);

    //Two types, rfc822 doesnt seem to work in the emulator
    msg.setType("text/plain");
    //msg.setType("message/rfc822");  

    //To:
    msg.putExtra(Intent.EXTRA_EMAIL, mEmailAddress);

    //Body:
    //msg.putExtra(Intent.EXTRA_TEXT, "");

    //Subject
    //msg.putExtra(Intent.EXTRA_SUBJECT, "");

    mActivity.startActivity(Intent.createChooser(msg, "chooser title"));

I am running this code sample in the emulator

Thanks Mark

Mark
  • 14,820
  • 17
  • 99
  • 159

2 Answers2

9

To: expects a string array:

intent.putExtra(EXTRA_EMAIL, new String[] { "some@example.com" });

And it will only run on a real device.
An example.

Community
  • 1
  • 1
yanchenko
  • 56,576
  • 33
  • 147
  • 165
0

Please use it like a String array

msg.putExtra(Intent.EXTRA_EMAIL, new String[] {mEmailAddress});

surya
  • 607
  • 5
  • 18