I'm trying to send an email with an HTML body. I have a String that contains some valid html:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
</head>
<body>%s</body>
</html>
from which I replace %s by some HTML.
Then I try to send this as an HTML email with the following code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, myhtmlcontent);
context.startActivity(Intent.createChooser(intent, context.getText(R.string.share)));
but I only receive the html source code as plain text
Now if I replace
intent.putExtra(Intent.EXTRA_TEXT, myhtmlcontent);
with
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(myhtmlcontent));
I receive a valid HTML email, but all my images have been replaced with some special character. Is there a way to keep my original html content and display it as a HTML email ?
Here's my full HTML code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body><p><a href="http://www.dailymars.net/wp-content/uploads/2014/05/Ant-Man.jpg"><img
class="aligncenter size-full wp-image-55602"
src="http://www.dailymars.net/wp-content/uploads/2014/05/Ant-Man.jpg" alt="Ant-Man"
width="720" height="302"/></a></p>
<p>Les enfants, l’heure est grave. Vous l’avez compris car vous l’avez lu dans le
titre de la news (eh ouaip!), <strong>Edgar Wright</strong> ne réalisera finalement pas <em>Ant
Man</em>. Alors qu’il était rattaché au projet depuis 2006 et qu’il en avait
écrit le scénario avec <strong>Joe Cornish</strong>, <strong>Marvel </strong>a annoncé que le
réal avait quitté le navire. La faute à quoi? Des « différences créatives »,
soit la meilleure excuse qu’Hollywood aie jamais inventé.</p>
<p><strong>Marvel </strong>a par ailleurs ajouté que le départ de <strong>Wright </strong> ne
changerait rien au casting ni à la date de sortie du film et qu’un remplaçant, dont le nom
devrait bientôt tomber, avait déjà été engagé. Dommage, ça n’aura pas la même saveur.</p>
<p><em>Ant Man</em> avec <strong>Paul Rudd, Michael Douglas, Evangeline Lilly, Corey Stoll, Michael
Pena</strong> et <strong>Patrick Wilson.</strong> Mais sans <strong>Edgar Wright</strong>.
Sortie en juillet 2015</p>
<p style="text-align: right;"><em>Source: <a
href="http://variety.com/2014/film/news/edgar-wright-leaves-marvels-ant-man-1201190458/">Variety</a></em>
</p>
</body>
</html>