2

I need to send HTML based content to email app using android intent extra . Its accept some tags like <BR> but its not showing any anchor link or <H1>, its shows like simple text .

EDITED : I have tried with gmail app

I have attached my code its in kotlin language

   val body="<a href=\"http://www.google.com\">clicke me</a>"
            val intent = Intent(Intent.ACTION_SENDTO)
            intent.setType("text/html")
            intent.data = Uri.parse("mailto:") // only email apps should handle this
            intent.putExtra(Intent.EXTRA_SUBJECT, "Subjecnew")
            intent.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(body))
            if (intent.resolveActivity(packageManager) != null) {
                startActivity(intent)
            }
Rakki s
  • 1,426
  • 1
  • 18
  • 42
  • It is up to the email client how to interpret `EXTRA_TEXT`. Different apps will have different levels of support. Also note that neither `EXTRA_TEXT` nor `EXTRA_SUBJECT` are documented for `ACTION_SENDTO`, so many apps will ignore those extras entirely. – CommonsWare Mar 29 '18 at 12:51
  • I have tested using gmail and Extra text and subjects are working, but it did not show the content as HTML it treat it as normal string – Rakki s Mar 29 '18 at 13:42

2 Answers2

5

Google has removed that feature from gmail application so its not possible to send tag content to gmail . Alternate is you can send that data from server

Rakki s
  • 1,426
  • 1
  • 18
  • 42
-1
final Intent shareIntent = new Intent(Intent.ACTION_SENDTO,      
Uri.parse("mailto:"));
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "The Subject");
shareIntent.putExtra(
Intent.EXTRA_TEXT,
Html.fromHtml(new StringBuilder()
    .append("<p><b>Some Content</b></p>")
    .append("<small><p>More content</p></small>")
    .toString())
);
MarAnd
  • 11
  • 6