首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Outlook将HTML显示为文本

Outlook将HTML显示为文本
EN

Stack Overflow用户
提问于 2011-08-21 18:35:05
回答 2查看 1.7K关注 0票数 1

我从我的红宝石rails应用程序发送电子邮件。所有电子邮件客户端显示我的电子邮件(gmail,蝙蝠,雷鸟等),但没有Outlook :(

在展望中,我看到这一点:

代码语言:javascript
复制
my message text

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: multipart/related; charset=f-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/plain; charset=f-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

my email text message

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/html; charset=f-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

my email html code (<h1>test</h1><table...)

--mimepart_4e514d8786c25_d59..fdab8042069c--

怎么了?

以防outlook中的标头:

代码语言:javascript
复制
Message-Id: <4e514d88.100fdf0a.403c.31a7@mx.xxx.ccc>
Subject: =?utf-8?Q?=D0=97=D0=B0=D0=BF=D1=80=D0=BE=D1=81_=D0=B4=D0=BB=D1=8F_=D0=BC=D0=B5=D0=BD=D0=B5=D0=B4=D0=B6=D0=B5=D1=80=D0=B0_=D0=BA=D0=BE=D0=BC=D0=BF=D0=B0=D0=BD=D0=B8=D0=B8_?=
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4e514d8786c25_d59..fdab8042069c
User-Agent: Rails Application
X-Mailer: Rails Mailer
Return-Path: admin@xxx.ccc
X-Yandex-Forward: 8a20ef6ffc7eeb7ef7c8d000508718e0

来自gmail的同一封电子邮件,在该邮件中,文本和html模式都显示得很好:

代码语言:javascript
复制
Delive
Message-Id: <4e514d88.100fdf0a.403c.31a7@mx.xxx.com>
Subject: xxx
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4e514d8786c25_d59..fdab8042069c
User-Agent: Rails Application
X-Mailer: Rails Mailer
X-Yandex-Forward: 8a20ef6ffc7eeb7ef7c8d000508718e0


--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: multipart/alternative; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

email text 


--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: multipart/related; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline


--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

email text (plain text)

--mimepart_4e514d8786c25_d59..fdab8042069c
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline


email text(html)

--mimepart_4e514d8786c25_d59..fdab8042069c--
EN

回答 2

Stack Overflow用户

发布于 2011-08-21 19:20:42

你是怎么构造这封邮件的?你手动添加标头了吗?

我不知道字符集=f-8是从哪里来的,但是它是一个bug,它使得包含Content-Type: text/html部分的整个标题行无效。你只是幸运的是,其他邮件客户不想在那里非常严格。

无效的标题行导致Outlook将部分解释为纯文本,这是相当明智的。

如果您没有手动添加这些标头,并且ActionMailer变得粗俗,请在构建邮件的地方发布一些代码。也许值得再提一个问题。

票数 3
EN

Stack Overflow用户

发布于 2012-01-24 20:19:31

(1)示例中的多部分结构是错误的;您需要实现这样的层次结构(使用适当的传输编码和其他细节):

代码语言:javascript
复制
Content-Type: multipart/alternative; boundary="LEVEL0"

--LEVEL0
Content-Type: text/plain; ...
email text...

--LEVEL0
Content-Type: multipart/related; boundary="LEVEL1"

--LEVEL1
Content-Type: text/html; ...
<html><body>...

--LEVEL1
Content-Type: image/jpeg; ...
...

--LEVEL1--

--LEVEL0--

(2)某些Outlook版本在为"text/ HTML“部分显式设置inline时不会直接显示html消息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7140236

复制
相关文章

相似问题

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