HTML 表格无法在 Outlook 中正确加载

标签 html css outlook fluid-layout

我有一个表格,第一行的列跨度为 3,下一行的 3 列包含图像。我尝试了多种形式的包装和 CSS,但无法正确加载电子邮件。 这是我修改过的代码和我开始使用的原始代码。我做错了什么?

到目前为止已修改

<html>
<head>
    <style>
        body{width: 100%; height: auto; background-color: #edebf1}
        <!--table{width: 100%; height: auto}-->
        <!--img{width: 100%!important; height: auto!important;}-->
        img{border:none; width: 100% !important;height:auto; line-    height:100%; outline:none;}
        .ExternalClass{width:100%; height: auto;}
        table {width: 100%; height: auto; border-collapse:separate;}
        td{cellpadding:0px; border-spacing:0px;}
        tr{cellpadding:0px; border-spacing:0px;}
    </style>
<title>Webinar Invite</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"     marginheight="0">

<!--[if mso]>
<table cellpadding="0" cellspacing="0" border="0"     style="padding:0px;margin:0px;width:100%;">
    <tr><td colspan="3" style="padding:0px;margin:0px;font-size:20px;height:20px;" height="20">&nbsp;</td></tr>
    <tr>
        <td style="padding:0px;margin:0px;">&nbsp;</td>
        <td style="padding:0px;margin:0px;" width="560">
<![endif]-->
        <table id="Table_01" width="8412" height="4183" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="3">
                    <img src="images/Webinar-Invite2_01.png" width="8412" height="2619" alt=""></td>
            </tr>
            <tr>
                <td>
                    <img src="images/Webinar-Invite2_02.png" width="3971" height="1564" alt=""></td>
                <td>
                    <a href="Webinar address" target="_Blank"
                    onmouseover="window.status='Registration for Webinar';  return true;"
                    onmouseout="window.status='';  return true;">
                        <img src="images/Webinar-Invite2_03.png" width="2042" height="1564" border="0" alt=""></a></td>
            <td>
                    <img src="images/Webinar-Invite2_04.png" width="2399" height="1564" alt=""></td>
            </tr>
        </table>
<!--[if mso]>
        </td>
        <td style="padding:0px;margin:0px;">&nbsp;</td>
   </tr>
    <tr><td colspan="3" style="padding:0px;margin:0px;font-size:20px;height:20px;" height="20">&nbsp;</td></tr>
</table>
<![endif]-->

</body>
</html>

原创

<html>
<head>
    <style>
        body{width: 100%; height: auto; background-color: #edebf1}
        table{width: 100%; height: auto}
        img{width: 100%; height: auto}
    </style>
<title>Webinar Invite2</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table id="Table_01" width="8412" height="4183" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="3">
            <img src="images/Webinar-Invite2_01.png" width="8412" height="2619" alt=""></td>
    </tr>
    <tr>
        <td>
            <img src="images/Webinar-Invite2_02.png" width="3971" height="1564" alt=""></td>
        <td>
            <a href="webinar address" target="_Blank"
                onmouseover="window.status='Registration for Webinar';  return true;"
                onmouseout="window.status='';  return true;">
                <img src="images/Webinar-Invite2_03.png" width="2042" height="1564" border="0" alt=""></a></td>
        <td>
            <img src="images/Webinar-Invite2_04.png" width="2399" height="1564" alt=""></td>
    </tr>
</table>
</body>
</html>

最佳答案

我运行你的代码,你可以用下面的代码替换你的代码:

<html>
<head>
    <style>
        body{width: 100%; height: auto; background-color: white; margin:0;}
        /* img{border:none; width: 100% !important;height:auto; line-height:100%; outline:none; display:inline-block} */
        .ExternalClass{width:100%; height: auto;}
        td{cellpadding:0px; border-spacing:0px;width:20px;height:20px;border: 1px solid #666666;}
        tr{cellpadding:0px; border-spacing:0px;}
        #Table_01{
            width:200px;
            height:200px; 
            border:0;
            border-collapse:separate;
            border: 1px solid #000000;
        }
        .tab_img{
           width:20px; 
            height:20px; 
            display:inline-block;
        }
        .tsb_img1{
            border:0;
        }
    </style>
<title>Webinar Invite</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
        <table id="Table_01" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="3">
                    <img src="" class="tab_img" alt=""></td>
            </tr>
            <tr>
                <td>
                    <img src=""  class="tab_img" alt=""></td>
                <td>
                    <a href="" target="_Blank"
                    onmouseover="window.status='Registration for Webinar';  return true;"
                    onmouseout="window.status='';  return true;">
                        <img src=" "  class="tab_img "  alt=""></a></td>
                <td>
                    <img src=""  class="tab_img" alt=""></td>
            </tr>
        </table>
</body>
</html>

这是我的 C# 代码:

static void Main(string[] args)
        {
            string stringHtmlBodyfromFile = File.ReadAllText(HTML file path);
             Outlook.Application objOutlook = new Outlook.Application();
            Outlook.MailItem mailItem = (Outlook.MailItem)(objOutlook.CreateItem(Outlook.OlItemType.olMailItem));
            mailItem.To = "";
           mailItem.Subject = "hi";
            mailItem.HTMLBody = stringHtmlBodyfromFile;
            Console.WriteLine(stringHtmlBodyfromFile);
            mailItem.Display();
        }

这是我的结果:

enter image description here

关于HTML 表格无法在 Outlook 中正确加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52503047/

相关文章:

使用 setTimeout() 方法在一段时间内更改背景颜色的 Javascript 函数

css - 如何在 bootstrap 移动版中隐藏网格中的一列

javascript - 如何在 native react 中在屏幕中间显示图标

outlook - 如何防止背景图像在 Outlook 2007 及更高版本中重复

html - 如何在标签和单选按钮之间添加空格? Bootstrap 4

javascript - PHP minifiying HTML - 跳过阅读 JavaScript 代码和 CSS?

html - Div 的定位 - 居中 + 固定问题

HTML 页脚被滚动条隐藏

c# - 使用 Graph API 时出现 "The tenant for tenant guid does not exist"- 用户类型为成员(member)的事件

c# - 删除 outlook session 请求