11

I would like to send HTML emails via an Intent. It seems that the accepted way to do this is as follows:

String body = "I am <b>bold text</b> and I am <i>italic text</i> and I am normal text.";

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(emailIntent, "Email:"));

This does not work in Gmail v6.11.2 and 7.1.129 and produces plain text output. The only tags I see recognized are <p> and <br>.

My email must be editable by the user, so sending it in background via JavaMail API is not an option.

I have also attempted: emailIntent.setType("message/rfc822");

and: emailIntent.putExtra(android.content.Intent.EXTRA_HTML_TEXT, "Hello I am <b>bold</b> text.");

If this was once working, can someone confirm that this is a regression in the Gmail app's functionality as suggested by this user: https://stackoverflow.com/a/41596827/1319081, or am I doing something wrong?

Community
  • 1
  • 1
rustyWhitefeather
  • 400
  • 1
  • 3
  • 12

1 Answers1

2
String body = new String("<html><body><table><tr><td><br/>" +header+"</td></tr><br/><br/>"+"Get <b> Best Score </b> in your Android Phone.<br/>"+"<a href=\"" + link_val + "\">" + text_value+ "</a>");

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, html.fromHtml(body));

Android support only some Tag.. For more information check below link..

Link 1

Link 2

Anchal Singh
  • 329
  • 3
  • 13