Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));
The above code opens a dialog showing following apps:- Bluetooth, Google Docs, Yahoo Mail, Gmail, Orkut, Skype etc.
Actually, I want to filter these list-options. I want to show only email related apps e.g. Gmail, Yahoo Mail. How to do it?
I've seen such example on 'Android Market' application.
- Open Android Market app
- Open any application where developer has specified his/her email address. (If you can't find such app just open my app:- market://details?id=com.becomputer06.vehicle.diary.free , OR search by 'Vehicle Diary')
- Scroll down to 'DEVELOPER'
- Click on 'Send Email'
The dialog shows only email Apps e.g. Gmail, Yahoo Mail etc. It does not show Bluetooth, Orkut etc. What code produces such dialog?
This is what I use, and it works for me:
This will also let the user choose their preferred email app. The only thing this does not allow you to do is to set the recipient's email address.
This is quoted from Android official doc, I've tested it on Android 4.4, and works perfectly. See more examples at https://developer.android.com/guide/components/intents-common.html#Email
Using
intent.setType("message/rfc822");
does work but it shows extra apps that not necessarily handling emails (e.g. GDrive). UsingIntent.ACTION_SENDTO
withsetType("text/plain")
is the best but you have to addsetData(Uri.parse("mailto:"))
to get the best results (only email apps). The full code is as follows:If you want only the email clients you should use
android.content.Intent.EXTRA_EMAIL
with an array. Here goes an example:Edit: Not working anymore with new versions of Gmail
This was the only way I found at the time to get it to work with any characters.
doreamon's answer is the correct way to go now, as it works with all characters in new versions of Gmail.
Old answer:
Here is mine. It seems to works on all Android versions, with subject and message body support, and full utf-8 characters support:
None of these solutions were working for me. Here's a minimal solution that works on Lollipop. On my device, only Gmail and the native email apps appear in the resulting chooser list.