我有一个表,其中第一行的列跨度为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"> </td></tr>
<tr>
<td style="padding:0px;margin:0px;"> </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;"> </td>
</tr>
<tr><td colspan="3" style="padding:0px;margin:0px;font-size:20px;height:20px;" height="20"> </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();
}
这是我的结果:
关于html - HTML表无法在Outlook中正确加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52503047/