AndroidManifest.xml
<uses-permission android:name="android.permission.SEND_EMAIL"/>
Java
String recipientEmail = "recipient@example.com"; String subject = "Your email subject"; String body = "Your email body"; Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:" + recipientEmail)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); }
Java
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); //emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body text startActivity(Intent.createChooser(emailIntent, "Chooser Title"));
Tags:
Android Studio