我已经进行了一些搜索,但我认为没有任何东西可以回答我对 GMail 4.6 版的问题
我的问题是我无法在从我创建的 Android 应用程序发送的电子邮件中呈现 HTML 格式。我正在使用定义了 text/html 类型的意图。我相信这个问题是由 GMail 应用程序引起的,因为它在发送之前从我的电子邮件中删除了 HTML。
我添加了可能导致问题的代码,除非它是 GMail。
String body =
"<table border='1'>" +
"<tr>" +
"<td>Paint Cost(Exc VAT)</td>" +
"<td>£" + String.format("%.2f", (subtotal - ((subtotal * 20)/100))) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Paint Cost(Inc VAT)</td>" +
"<td>£" + String.format("%.2f", subtotal) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Undercoat Cost(Exc VAT)</td>" +
"<td>£" + String.format("%.2f", (undercoat - ((undercoat * 20)/100))) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Undercoat Cost(Inc VAT)</td>" +
"<td>£" + String.format("%.2f", undercoat) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Total Cost(Exc VAT)</td>" +
"<td>£" + String.format("%.2f", (total - ((total * 20)/100))) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Total Cost(Inc VAT)</td>" +
"<td>£" + String.format("%.2f", total) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Total VAT</td>" +
"<td>£" + String.format("%.2f", ((total *20)/100)) + "</td>" +
"</tr>" +
"</table>";
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{email});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Paint Cost");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body)
);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
提前致谢。
编辑 1
String body =
"<table border='1'>" +
"<tr>" +
"<td>Paint Cost(Exc VAT)</td>" +
"<td>£" + String.format("%.2f", (subtotal - ((subtotal * 20)/100))) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Paint Cost(Inc VAT)</td>" +
"<td>£" + String.format("%.2f", subtotal) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Undercoat Cost(Exc VAT)</td>" +
"<td>£" + String.format("%.2f", (undercoat - ((undercoat * 20)/100))) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Undercoat Cost(Inc VAT)</td>" +
"<td>£" + String.format("%.2f", undercoat) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Total Cost(Exc VAT)</td>" +
"<td>£" + String.format("%.2f", (total - ((total * 20)/100))) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Total Cost(Inc VAT)</td>" +
"<td>£" + String.format("%.2f", total) + "</td>" +
"</tr>" +
"<tr>" +
"<td>Total VAT</td>" +
"<td>£" + String.format("%.2f", ((total *20)/100)) + "</td>" +
"</tr>" +
"</table>";
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{email});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Paint Cost");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, Html.fromHtml(body)
);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
但是,这似乎会使 GMail 应用程序崩溃。