Reputation: 2707
I need to send an e-mail from my Android application. So, I send 2 parameters ( e-mail and subject) to the e-mail client app, but when app opens e-mail client, there is only subject parameter added, and email parameter is not set.
How I can fix this?
String getMail = email.toString();
Log.d("GET MAIL:",getMail);
String subject = "Subject";
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
// need this to prompts email client only
emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent,"Choose E-mail client:"));
Upvotes: 1
Views: 251
Reputation: 4255
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From App");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Upvotes: 3
Reputation: 3025
Change emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);
to:
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{getMail});
Upvotes: 2