【问题标题】:Email Blast HTML Sizing Issues电子邮件 Blast HTML 大小问题
【发布时间】:2026-01-29 15:20:10
【问题描述】:

所以我正在构建一个电子邮件爆炸,并且对 HTML 特定的电子邮件爆炸相当陌生,我的图像和链接工作正常,但我的问题是在手机上查看爆炸时,我尝试嵌入的媒体查询是不工作。

我正在使用 ASP.NET 和 HTML 来执行爆炸。但我担心我可能包含了太多的 css 或者不足以根据屏幕调整身体的大小。

如果有人可以查看我的代码并查看我可能出错的地方,我将不胜感激。

     Dim emailmess As New MailMessage()
            emailmess.From = New MailAddress("example@example.com")
            emailmess.To.Add(New MailAddress("example@example.com"))
            emailmess.IsBodyHtml = True
            emailmess.Subject = "Aures Email Blast Test"
            emailmess.Body = "<html><head><style type='text/css'>@media screen and (max-width:600px){table[class='container-table'] {width: 100% !important;}}</style></head><body margin='0' padding='0'><table class='container-table' cellspacing='0' cellpadding='0' style='max-width: 600px; width:100%; height:100%; max-height: 800px;' background='http://www.becub3d.com/Aures_Eblast_F.png'><tr><td><table class='container-table' cellspacing='0' cellpadding='0' border='0' cellspacing='0' cellpadding='0' style='margin-top:107%; max-width:600px; height:9%; width:100%;' ><tr><td align='left' style='width:42px;'></td><td style='width:100px;cursor:pointer;' ><a href='https://www.aures.com/en/Contact/main-aures-contact' style='display:block; text-decoration:none; height:70px;'>&nbsp;</a></td><td style='width:20px;'></td><td style='width:100px;cursor:pointer;' ><a href='https://www.youtube.com/watch?v=en_LPS_gfXY' style='display:block; text-decoration:none; height:70px;'>&nbsp;</a></td><td style='width:20px;'></td><td style='width:100px;cursor:pointer;' ><a href='https://www.aures.com/en/point-of-sale-equipment-solutions-systems/yuno-touchscreen-terminal-multi-configuration' style='display:block; text-decoration:none; height:70px;'>&nbsp;</a></td><td style='width:37px;'></td></tr></table><table class='container-table' cellspacing='0' cellpadding='0' width='600' height='30'><tr><td></td></tr></table><table class='container-table' cellspacing='0' cellpadding='0' width='600' height='10' border='0' cellspacing='0' cellpadding='0'><tr><td style='width:440px;'></td><td style='width:75px;cursor:pointer;' ><a href='www.auresusa.com' style='display:block; text-decoration:none;'>&nbsp;</a></td><td></td></tr></table><table class='container-table' cellspacing='0' cellpadding='0' width='600' height='16'><tr><td style='width:290px;'></td><td style='width:15px;cursor:pointer;' ><a href='https://www.linkedin.com/company/aures-technologies-inc' style='display:block; text-decoration:none;'>&nbsp;</a></td><td></td></tr></table></td></tr></table></body></html>"
            Dim thesmtp As New SmtpClient("webmail.example.com")
            thesmtp.Credentials = New System.Net.NetworkCredential("example@example.com", "password")
            thesmtp.Port = 25
            thesmtp.EnableSsl = False
            thesmtp.Send(emailmess)

HTML 字符串在下面分解

<html>
<head>
    <style type='text/css'>@media screen and (max-width:600px){table[class='container-table'] {width: 100% !important;}}</style>
</head>
<body margin='0' padding='0'>
    <table class='container-table' cellspacing='0' cellpadding='0' style='max-width: 600px; width:100%; height:100%; max-height: 800px;' background='http://www.becub3d.com/Aures_Eblast_F.png'>
        <tr>
            <td>
                <table class='container-table' cellspacing='0' cellpadding='0' border='0' cellspacing='0' cellpadding='0' style='margin-top:107%; max-width:600px; height:9%; width:100%;' >
                    <tr>
                        <td align='left' style='width:42px;'></td>
                        <td style='width:100px;cursor:pointer;' >
                            <a href='https://www.aures.com/en/Contact/main-aures-contact' style='display:block; text-decoration:none; height:70px;'>&nbsp;</a>
                        </td>
                        <td style='width:20px;'></td>
                        <td style='width:100px;cursor:pointer;' >
                            <a href='https://www.youtube.com/watch?v=en_LPS_gfXY' style='display:block; text-decoration:none; height:70px;'>&nbsp;</a>
                        </td>
                        <td style='width:20px;'></td>
                        <td style='width:100px;cursor:pointer;' >
                            <a href='https://www.aures.com/en/point-of-sale-equipment-solutions-systems/yuno-touchscreen-terminal-multi-configuration' style='display:block; text-decoration:none; height:70px;'>&nbsp;</a></td><td style='width:37px;'>
                        </td>
                    </tr>
                </table>
                <table class='container-table' cellspacing='0' cellpadding='0' width='600' height='30'>
                    <tr>
                        <td></td>
                    </tr>
                </table>
                <table class='container-table' cellspacing='0' cellpadding='0' width='600' height='10' border='0' cellspacing='0' cellpadding='0'>
                    <tr>
                        <td style='width:440px;'></td>
                        <td style='width:75px;cursor:pointer;' >
                            <a href='www.auresusa.com' style='display:block; text-decoration:none;'>&nbsp;</a>
                        </td>
                        <td></td>
                    </tr>
                </table>
                <table class='container-table' cellspacing='0' cellpadding='0' width='600' height='16'>
                    <tr>
                        <td style='width:290px;'></td>
                        <td style='width:15px;cursor:pointer;' >
                            <a href='https://www.linkedin.com/company/aures-technologies-inc' style='display:block; text-decoration:none;'>&nbsp;</a>
                        </td>
                        <td></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body></html>

【问题讨论】:

  • 我也查看了您的 HTML,似乎 HTML 中有一些错误。如果您在 HTML 编辑器中查看 HTML STRING BROKEN DOWN BELOW 并查找第 9 行和第 30 行,您会发现 cellpadding 和 cellspacing 加倍。正如 Gwally 所说,编码电子邮件不像网络,你的 CSS 必须是内联的,图像应该在 HTML 中。我不建议使用完全基于图像的电子邮件,因为它可能会导致不同 EPS 的交付问题。如果您确实想发送基于图像的电子邮件,请将其分成几部分。

标签: html css asp.net html-email mail-server


【解决方案1】:

我查看了您的代码,并以此代码为例进行了回答:

&lt;table class='container-table' cellspacing='0' cellpadding='0' style='max-width: 600px; width:100%; height:100%; max-height: 800px;' background='http://www.becub3d.com/Aures_Eblast_F.png'&gt;

您在表格的背景中使用图像。背景图像不会调整大小,只是表格。图像通常保持相同大小。

这也将确保您的图像不会显示在不支持背景图像的 Outlook 中。这就是为什么它在 IOS 设备上看起来很糟糕,而不是在 Android 上显示。

用于电子邮件的 HTML 与 Web 开发不同。它使用比 HTML 5 开发更小的 CSS 代码库。它不支持您在现代浏览器中看到的所有代码。实际上,Microsoft Outlook 的渲染引擎是基于 Word 的。您应该查看 Campaign Monitor CSS 合规性表:

我可能会建议您查找一个有效的 html 响应式电子邮件模板,研究它如何处理图像并从那里开始。我建议像 Zurb Foundation for Emails 这样的东西:

祝你好运。

【讨论】:

  • 您能否建议一个更可接受的位置来使用图像并且仍然响应。作为bg图像放置在body中会更好吗?或者也许是 DIV 而不是使用表格作为初始持有者?感谢您的链接,现在查看它们