2

我已经进行了一些搜索,但我认为没有任何东西可以回答我对 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 应用程序崩溃。

4

1 回答 1

0

邮件客户端,当通过 调用时ACTION_SEND,允许用户编辑消息,并且并非所有邮件客户端都提供对所有可能的 HTML 标记的编辑。特别是那些EditText用作编辑器基础的人不太可能支持 HTML 平板电脑。

于 2013-10-18T13:46:11.247 回答