Send HTML email with Android formatting (inline style)

Question:

I'm trying to send a custom email via new Intent(Intent.ACTION_SEND) , containing formatted HTML in the email body, but when selecting the Gmail app, for example, the entire html style is ignored. What I'm trying to do is:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/html");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"destino@mail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<h1>Sou um H1</h1><p>Eu sou um paragrafo</p><p style=\"color:red;background-color:black;\">Eu sou um paragrafo colorido!</p>"));
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(getActivity(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

The email application is called correctly, but the style part of the HTML is lost. Is it possible to keep the HTML intact in this way of sending email via Intent.ACTION_SEND ?

Answer:

Just use the Intent.EXTRA_HTML_TEXT parameter

i.sendIntent.setType(“text/html”);

i.putExtra(Intent.EXTRA_HTML_TEXT, Html.fromHtml("<h1>Sou um H1</h1><p>Eu sou um paragrafo</p><p style=\"color:red;background-color:black;\">Eu sou um paragrafo colorido!</p>").toString());

WHERE

i.putExtra(Intent.EXTRA_HTML_TEXT, "<h1>Sou um H1</h1><p>Eu sou um paragrafo</p><p style=\"color:red;background-color:black;\">Eu sou um paragrafo colorido!</p>");
Scroll to Top
AllEscort