问题描述
我想通过一个Intent发送HTML电子邮件.似乎可以接受的方法如下:
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:"));
这在Gmail v6.11.2和7.1.129中不起作用,并产生纯文本输出.我看到的唯一识别的标签是< p>
和&br; br>
.
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>
.
我的电子邮件必须可由用户编辑,因此不能通过JavaMail API在后台发送.
My email must be editable by the user, so sending it in background via JavaMail API is not an option.
我也尝试过: emailIntent.setType("message/rfc822");
和: emailIntent.putExtra(android.content.Intent.EXTRA_HTML_TEXT,你好,我是< b> bold</b>文本.");
如果此操作曾经有效,是否有人可以确认这是该用户建议的Gmail应用功能的回归: https://stackoverflow.com/a/41596827/1319081 ,还是我做错了什么?
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?
推荐答案
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仅支持某些标签.有关更多信息,请单击下面的链接.
Android support only some Tag..For more information check below link..
这篇关于Android的Gmail应用程序是否删除了通过Intent发送HTML电子邮件的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!