【问题标题】:Dynamic list in html email templatehtml电子邮件模板中的动态列表
【发布时间】:2019-07-09 17:35:14
【问题描述】:

我正在使用简单的 HTML 创建电子邮件模板。但是我被困在必须列出哪些数据来自java代码的列表的地方。另外,我不确定每次得到的列表的长度。

我尝试过类似下面的代码。但它没有用。

<span style="font-size:19px;font-weight:bold;font-family: Calibri;">Dear $customer,</b></span><br>
<br>
<br>
<span style="font-size:14px;font-family: Calibri;">Below List of Products orderd</br>
<table>
  <tr>
    <th><ul>
        <li>$ProdID</li>
      </ul></th>
    <th><ul>
        <li>$PrdoName</li>
      </ul></th>
  </tr>
</table>
<br>
Thank you for choosing US </br>
</br>
Genuinely,<br />
<br />
<span style="font-size:16px; font-weight:bold;font-family: Calibri;">E - commerce</span></span>
</div>
</td>
</tr>
<tr>
  <td><hr noshade size=1 width="100%" style="margin:0" align=left>
    <div id="footerTxt" style=" font-family: Calibri;line-height:18px; margin:20px 0;">
    <span style="font-size:12px; color:#999"><br />
    &copy;E-Commerce L.P. </span>

请帮我将 $prodID 打印为列表,我已将值作为字符串列表传递

【问题讨论】:

  • 您正在使用ul & li。你试过桌子吗?这将很容易并且看起来会更好。看看有没有数据可以填写表格的列和行。
  • 你用的是java还是php?因为据我所知 $ProdID 和 $PrdoName 代表 PHP 变量
  • 此外,html 也不正确。因为你在“Thank you for selection US”之前已经关闭了表格,然后下面我们可以看到关闭的参考
  • @SandhyaNair 我正在使用 java

标签: html html-email


【解决方案1】:

我假设用于 html 模板的语言是 PHP,因为变量前面有 $ 符号。请参考下面的代码

<table cellpadding="0" cellspacing="0" width="100%">
  <tr>
      <td><span style="font-size:19px;font-weight:bold;font-family: Calibri;">Dear <?php echo $customer?>,</span></td>
  </tr>
  <tr>
      <td><span style="font-size:14px;font-family: Calibri;">Below List of Products ordered:</span></td>
  </tr>
   <tr>
       <td>
           <table cellpadding="0" cellspacing="0" width="100%">
               <tr>
                   <th>Prod ID</th>
                   <th>Prod Name</th>
               </tr>
               <?php foreach($products as $product) {?>
               <tr>
                   <td><?php echo $product->prodID ?></td>
                   <td><?php echo $product->prodName ?></td>
               </tr>
               <?php } ?>
           </table>
       </td>
   </tr>
    <tr>
        <td>
            Thank you for choosing US </br>
            Genuinely,<br /><br />
            <span style="font-size:16px; font-weight:bold;font-family: Calibri;">E - commerce</span></span>
        </td>
    </tr>
    <tr>
        <td>
            <hr noshade size=1 width="100%" style="margin:0" align=left>
            <div id="footerTxt" style=" font-family: Calibri;line-height:18px; margin:20px 0;"><span style="font-size:12px; color:#999"><br />&copy;E-Commerce L.P. </span></div>
        </td>
    </tr>
</table>

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签