i am trying to create an intent activity that sends an email. Using
public void emailSend(View view){
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("plain/text");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Nächstes Treffen");
emailIntent.putExtra(Intent.EXTRA_EMAIL,adressListe);
if (emailIntent.resolveActivity(getPackageManager()) != null){
startActivity(emailIntent);
}
}
offers me more than just the email apps. Using
public void emailSend(View view){
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("plain/text");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Nächstes Treffen");
emailIntent.putExtra(Intent.EXTRA_EMAIL,adressListe);
if (emailIntent.resolveActivity(getPackageManager()) != null){
startActivity(emailIntent);
}
}
Nothing happens when i click the button. For
emailIntent.setType("plain/text");
is also tried
emailIntent.setType("messageage/rfc822");
and
emailIntent.setType("*/*");
all with varying results, but none only dislaying the email apps.
Do you have any idea how to solve this? Help would be greatly appreciated!
Thanks!
When I use intent android.content.Intent.ACTION_SENDTO doesn't work for me because it shows many apps, some apps are not email clients. I found this way and it works perfectly for me.
Intent testIntent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + "text subject" + "&body=" + "text content" + "&to=" + "[email protected]");
testIntent.setData(data);
startActivity(testIntent);
I see only email clients when using the next approach:
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String [] {[email protected]});
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"Email subject"));
Intent chooser = Intent.createChooser(emailIntent, "Mail to ..");
if (emailIntent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
else
//Do something if there's no Email client
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With