简体   繁体   English

Outlook 2010和Gmail中的HTML呈现

[英]HTML rendering in Outlook 2010 and Gmail

I am programmatically sending a full HTML message to 2 persons... 1 is a Gmail user and the other is a private host using Outlook... the message is the following: 我正在以编程方式将完整的HTML消息发送给2个人... 1是Gmail用户,另一个是使用Outlook的私人主机...该消息如下:

<html xmlns="http://www.w3.org/1999/xhtml\">
<body background="http://sa-tips-spint1:103/_layouts/images/corrente%20do%20bem/2010/cartao.jpg" BGCOLOR="#000000" style="background-position: center top;
                 margin-left: 0px;
                 margin-top: 0px;
                 margin-right: 0px;
                 margin-bottom: 0px;">
    <div align="center">
        <p>&nbsp;</p>
    </div>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="827" height="69" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
            <td width="504">&nbsp;</td>
            <td width="323" valign="top">
                <p style="color:'#FFFF66';font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px;">Ola,</p>
                <p style="color:'#FFFF66';font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px;"> MY HAPPY MESSAGE </p>
            </td>
        </tr>
    </table>
</body>
</html>

the problem with the Gmail... is that the image does not show up and the background does not apply and no kind of CSS is applied... leaving only the MY HAPPY MESSAGE... Gmail的问题...是图片未显示且背景不适用,并且未应用任何CSS ...仅留下了MY HAPPY MESSAGE ...

and the problem with the Outlook is that if i use css... css does not render properly... all css except the background-image... can anyone help me? 和Outlook的问题是,如果我使用css ... css无法正确呈现...除背景图像以外的所有css ...有人可以帮助我吗?

As you can see from this Answer in SO . 如您从SO中的Answer所见。 Gmail blocks images by default. Gmail默认会阻止图像。 You can't do anything about it as a sender. 作为发件人,您无法做任何事情。

All modern mail readers disable images and other external references by default. 默认情况下,所有现代邮件阅读器均禁用图像和其他外部引用。 They will stay disabled until the user enables the images for the one message or tells the reader program to always enable images when receiving from that account. 它们将保持禁用状态,直到用户为一条消息启用图像或告诉阅读器程序从该帐户接收到图像时始终启用图像。 It's usually a good idea to just respect this and not provide external references if you don't absolutely have to. 通常,最好是尊重这一点,如果不需要的话,不要提供外部参考。

The only way around this that I am aware of is if you actually embed the image in the email itself. 我知道的解决此问题的唯一方法是,是否将图像实际嵌入到电子邮件本身中。 In other words, the entire message becomes self contained. 换句话说,整个消息成为独立的。

Also, most email applications (especially web based ones) strip out the HTML, HEAD, and BODY tags. 同样,大多数电子邮件应用程序(尤其是基于Web的电子邮件应用程序)会去除HTML,HEAD和BODY标签。 If you think about it you'll understand why. 如果您考虑一下,您将理解原因。 If you really need a background image, move that image to a div just inside the body. 如果您确实需要背景图片,请将其移到体内的div。 Like <body><div style="...">CONTENT</div></body> 就像<body><div style="...">CONTENT</div></body>

One final note because those outer tags are removed, you should move any CSS classes to be below the BODY tag. 最后一点要注意的是,由于这些外部标记已被删除,因此您应将所有CSS类移到BODY标记之下。

The main thing to take away from this is that you will have to break a lot of standardization rules in order to get HTML email to work. 要摆脱的主要问题是,您必须打破许多标准化规则才能使HTML电子邮件正常工作。 finally, you might read this link from Ros Hodgekiss. 最后,您可以阅读Ros Hodgekiss的此链接 It's a relatively new post that talks about gmail and outlook 07/10; 这是一个相对较新的文章,谈论gmail和Outlook 07/10; I haven't tested it myself, but it sounds pretty well researched. 我自己还没有测试过,但是听起来很不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM