首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Html不像Gmail那样在电子邮件客户端呈现

Html不像Gmail那样在电子邮件客户端呈现
EN

Stack Overflow用户
提问于 2017-06-15 11:09:17
回答 1查看 149关注 0票数 0

我使用Html.fromHtml呈现HTML并将其传递给emailIntent。

代码语言:javascript
复制
                        Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                                "mailto","", null));

                        ///emailIntent.setType("text/html");
                        emailTemplate = emailTemplate.replaceAll("(\r\n|\n)", "<br />").trim();

                        emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

                        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "");

                        Spanned shareBody = null;//remove it's instance...

                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                            Spanned spanned = Html.fromHtml(emailTemplate ,Html.FROM_HTML_MODE_LEGACY);
                            shareBody = spanned;
                            ///emailTemplate = spanned.toString();
                        }
                        else
                        {
                            Spanned spanned =  Html.fromHtml(emailTemplate);
                            shareBody = spanned;
                            ///emailTemplate = spanned.toString();
                        }

                        emailIntent.putExtra(Intent.EXTRA_TEXT, shareBody);//emailTemplate);
                        mContext.startActivity(Intent.createChooser(emailIntent, "Send email..."));

emailTemplate在哪里

代码语言:javascript
复制
"\u003ctable id=\"pltrlText\" style=\"width:100%; display:block; margin:0px; padding:0px;\"\u003e \u003ctbody style=\"display: block;\"\u003e \u003ctr style=\"display: block; margin: 0px 5px 30px 5px; \"\u003e \u003ctd style=\"font-family: \u0027OpenSansRegular\u0027, Arial; color: #444444; font-size: 14px; \"\u003e HI[Razi] \u003c/td\u003e \u003c/tr\u003e \u003ctr style=\"display: block; margin: 0px 5px 30px 5px; \"\u003e \u003ctd style=\"font-family: \u0027OpenSansRegular\u0027, Arial; color: #444444; font-size: 14px; \"\u003e We are happy to offer you solutions, that make a positive impact on your business. We are happy to offer you solutions, that make a positive impact on your business. We are happy to offer you solutions, that make a positive impact on your business. We are happy to offer you solutions, that make a positive impact on your business.We are happy to offer you solutions, that make a positive impact on your business. We are happy to offer you solutions, that make a positive impact on your business. \u003c/td\u003e \u003c/tr\u003e \u003c/tbody\u003e \u003c/table\u003e"

没有下一行显示,也没有应用样式。我做错什么了。也尝试过用绳子和跨。

和无样式的工作方式类似于颜色和背景,

但同样适用于IOS应用程序gmail客户端和其他客户端。

EN

回答 1

Stack Overflow用户

发布于 2017-06-15 11:26:23

我做错什么了。

假设您可以使用任意HTML。在任何平台(包括Web邮件)上,很少有电子邮件客户端在电子邮件合成器中支持任意HTML。

对于Android来说,一般情况下,预期只限于Html.fromHtml()Html.toHtml()支持的标记。值得注意的是,考虑到您非常奇怪的模板:

  • 不支持<table> (以及<tr><td>)
  • 大多数style位都不受支持。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44565989

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档