Email body doesn't show when using an Intent
Solution 1:
To send an email with a body, use message/rfc822.
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("message/rfc822");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]", "[email protected]" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject of the email");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Content of the email");
startActivity(sendIntent);
Hope this helps.
Solution 2:
I use body properties for gmail and EXTRA_TEXT for other email. I've tested for different email app such as samsung email, oneplus email, and LG email, they seems to support EXTRA_TEXT but gmail is supporting "body" properties.
fun composeEmailMessage(context: Context, subject: String, body: String, emails: Array<String> = arrayOf()) {
val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("mailto:")
intent.putExtra(Intent.EXTRA_EMAIL, emails)
intent.putExtra(Intent.EXTRA_SUBJECT, subject)
intent.putExtra(Intent.EXTRA_TEXT, body)//other emails app
intent.putExtra("body", body)//gmail
if (intent.resolveActivity(context.packageManager) != null) {
context.startActivity(Intent.createChooser(intent, "Send email via..."))
}
}