【发布时间】:2014-07-13 21:29:29
【问题描述】:
我正在尝试发送带有 HTML 正文的电子邮件。 我有一个包含一些有效 html 的字符串:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
</head>
<body>%s</body>
</html>
我用一些 HTML 替换 %s。
然后我尝试使用以下代码将其作为 HTML 电子邮件发送:
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)));
但我只收到纯文本形式的 html 源代码
现在如果我替换
intent.putExtra(Intent.EXTRA_TEXT, myhtmlcontent);
与
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(myhtmlcontent));
我收到了一封有效的 HTML 电子邮件,但我的所有图片都已替换为某些特殊字符。有没有办法保留我的原始 html 内容并将其显示为 HTML 电子邮件?
这是我的完整 HTML 代码
<!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>
【问题讨论】:
-
没用。我知道显示图像需要用户接受。我的问题是我要么以纯文本形式接收我的 html 源代码,要么我正在接收 HTML 但图像被 Html.fromHtml() 剥离...
标签: android html email android-intent