1

I'm using the following to initiate the sending of an email:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc882"); 
i.putExtra(Intent.EXTRA_EMAIL, new String[]{s});
startActivity(Intent.createChooser(i, "Send mail..."));

The problem that I'm having is that (on my phone) it pulls up Gmail's Compose window instead of allowing me to choose which email client I'd like to send the message with.

Am I doing this wrong, or does the default email client just not respond to email send intents?

Jeremy Logan
  • 47,151
  • 38
  • 123
  • 143

2 Answers2

0

It's a common misconception to use text/plain. This will trigger any application that can handle plain text files without any context, including Google Drive, Dropbox, Evernote and Skype.

Instead use a ACTION_SENDTO, providing the mailto: Uri:

intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"));
startActivity(intent);
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
  • Great answer - Sends it directly to the mail client rather than 8+ options (including Google Drive which is a valid target of ACTION_SEND and is present on most devices even with "text/plain" specified. – Graeme Apr 03 '13 at 15:52
0

It might not respond to message/rfc882 Intents. Try text/plain instead, if you can, as I'm pretty sure that works.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Stupid me... I *thought* I'd tried that already, but it turns out I typed in `plain/text` instead of `text/plain`. Sigh. – Jeremy Logan Nov 24 '09 at 23:58
  • Actually, that might indirectly be my fault. There's a snippet from AndroidSnippets.org that I sometimes point to and clip from, and *that* has plain/text instead of text/plain. Odds are, you got the typo from there. – CommonsWare Nov 25 '09 at 00:44
  • Maybe... I can't remember. I DID google around for it, but that was a week or two ago. – Jeremy Logan Nov 25 '09 at 18:48
  • Men, I used the same stupid snippet from somewhere. Guess it's quite widespread. – Peterdk Apr 30 '11 at 19:53
  • This intent isn't strictly for sending e-mail. It's for sharing to an application that accepts data in plain text format. It just so happens to be that Gmail matches that constraint. – Paul Lammertsma Mar 01 '13 at 09:24