Android Studio Mailto Intent Doesn't Show Subject and Mail Body

Android Studio mailto Intent doesn't show subject and mail body

try out this code, it worked for me.

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject here");
intent.putExtra(Intent.EXTRA_TEXT,"Body Here");
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}

also add intent filter in android manifest.

<activity ...>
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Email Intent subject is ignored in gmail, but works with other mail clients

Gmail seems to ignore Intent extras. Try this instead:

Intent j = new Intent(Intent.ACTION_SENDTO);
j.setData(Uri.parse("mailto:appsupport@prali.in" +
"?subject=Request approval for Kiranam Registration - " + KiranamUserId));
j.putExtra(Intent.EXTRA_SUBJECT, "Request approval for Kiranam Registration - " + KiranamUserId);
startActivity(Intent.createChooser(j, "Select your mail account to send mail for Approval"));

Email ID , Subject and Message not setting in android Send Intent

I also faced this problem. Be clear that those string values are not null. You could also use ACTION.SENDTO. Use the below code; it worked for me.

    Intent sendMail = new Intent(Intent.ACTION_SENDTO);
sendMail.setData(Uri.parse("mailto:"));
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.setSelector( sendMail );
startActivity(Intent.createChooser(intent, "Choose an Email Client"));

Android ACTION_SEND intent not populating Subject or Body

The following code works for me (just tried it):

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"foo@bar.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Choose email...");
} catch (android.content.ActivityNotFoundException ex) {
// handle edge case where no email client is installed
}

Email body empty when select to send email by Gmail

Thanks for help

Made tests with lots of suggested answers.
adding "text/plain" or "message/rfc822" made my app to stop offering mail clients.

Fount this answer that fixed my issue:
https://stackoverflow.com/a/59365539/973233

Most interesting part for me is having 2 intents:

Intent selectorIntent = new Intent(Intent.ACTION_SENDTO);
selectorIntent.setData(Uri.parse("mailto:"));
final Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, text);
emailIntent.setSelector( selectorIntent );
activity.startActivity(Intent.createChooser(emailIntent, "Send feedback to XYZ"));

This solved problem.

Email body doesn't show when using an Intent

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[] { "to1@example.com", "to2@example.com" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject of the email");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Content of the email");
startActivity(sendIntent);

Hope this helps.

Send Email Intent

when you will change your intent.setType like below you will get

intent.setType("text/plain");

Use android.content.Intent.ACTION_SENDTO to get only the list of e-mail clients, with no facebook or other apps. Just the email clients.
Ex:

new Intent(Intent.ACTION_SENDTO);

I wouldn't suggest you get directly to the email app. Let the user choose his favorite email app. Don't constrain him.

If you use ACTION_SENDTO, putExtra does not work to add subject and text to the intent. Use Uri to add the subject and body text.

EDIT:
We can use message/rfc822 instead of "text/plain" as the MIME type. However, that is not indicating "only offer email clients" -- it indicates "offer anything that supports message/rfc822 data". That could readily include some application that are not email clients.

message/rfc822 supports MIME Types of .mhtml, .mht, .mime



Related Topics



Leave a reply



Submit