c# MailMessage HTML 字符串 style='margin-bottom:-2px' 不起作用



我正在创建邮件,然后将一些HTML代码放在字符串(邮件正文)中,该代码将发送到替代视图(将其设置在MailMessage中)。

问题是在图像中我添加了margin-bottom的样式属性,并且它在接收的邮件(Gmail)中没有任何效果。

检查图像对象进入gmail后,属性样式似乎已经消失。

这是HTML内容(由我的测试应用程序生成)在发送邮件之前通过断点处于调试状态:

<h2><strong>Ratio :</strong> 80%<br><strong>Total Tests Count :</strong> 5<br /><strong>Total Tests Pass&nbsp;:</strong> 4</h2>
<br>
<hr>
<br>
<h2> <img src='cid:imgUITPR' width="16" height="16"/><strong> UITestPlan </strong > 'AssignHoursProfileToDriver' (TestSuites : 3) : <font color='#FF5252'>Failed</font></h2>
<h3> <img src='cid:imgUITSR' width="16" height="16" style='margin-bottom: -2px;' /><strong > UITestSuite </strong > 'CreateDriver' (Tests : 4) : <font color='#FF5252'>Failed</font></h3>
<h4> <img style='margin-bottom: -3px;' src='cid:imgUITG' width="16" height="16"  /><strong > UITest </strong > 'OpenDriversModule' (Steps : 1) : <font color='#4CAF50'>Pass</font></h4>
<h4> <img style='margin-bottom: -3px;' src='cid:imgUITG' width="16" height="16"  /><strong > UITest </strong > 'ClickOnCreateDriver' (Steps : 1) : <font color='#4CAF50'>Pass</font></h4>
<h4> <img style='margin-bottom: -3px;' src='cid:imgUITG' width="16" height="16"  /><strong > UITest </strong > 'FillNewDriverDetails' (Steps : 4) : <font color='#4CAF50'>Pass</font></h4>
<h4> <img style='margin-bottom: -3px;' src='cid:imgUITR' width="16" height="16"  /><strong > UITest </strong > 'ClickOnValidate' (Steps : 1) : <font color='#FF5252'>Failed</font></h4>
<h3> <img src='cid:imgUITS' width="16" height="16" style='margin-bottom: -2px;' /><strong > UITestSuite </strong > 'CreateHoursProfile' (Tests : 1) : <strong>Ignored</strong></h3>
<h4> <img style='margin-bottom: -3px;' src='cid:imgUIT' width="16" height="16"  /><strong > UITest </strong > 'OpenConfigurationModule' (Steps : 1) : <strong>Ignored</strong></h4>
<h3> <img src='cid:imgUITS' width="16" height="16" style='margin-bottom: -2px;' /><strong > UITestSuite </strong > 'AssignProfileToDriver' (Tests : 0) : <strong>Ignored</strong></h3>

编辑:我使用了负余量,Gmail作为Outlook和Yahoo不支持负余量。

我在第9点的博客文章中看到了:

gmail不允许负CSS保证金值

看来WebMail客户端倾向于完全忽略保证金。

最新更新