Mark
Mark

Reputation: 14930

Android ACTION_SEND Intent not populating the To field

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

Upvotes: 2

Views: 1721

Answers (2)

surya
surya

Reputation: 607

Please use it like a String array

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

Upvotes: 0

yanchenko
yanchenko

Reputation: 57176

To: expects a string array:

intent.putExtra(EXTRA_EMAIL, new String[] { "[email protected]" });

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

Upvotes: 9

Related Questions