You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Problems generating an email using an HTML template

posted on April 8, 2025

Hi

I'm trying to generate an email with a specific format using HTML. It handles the data correctly, but it makes jumps that theoretically shouldn't and modifies the margins. When I export the HTML code to a file and open it in major browsers, it displays perfectly.
The other times I've tried using formats like this, this always happens.

Thanks

Ricardo

 

This is the code I'm using.

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Notificación de Cheques</title>
</head>
<body style="margin:0; padding:0; font-family: Arial, sans-serif; font-size: 13px; color: #000;">

  <table align="center" cellpadding="0" cellspacing="0" border="0" width="600" style="border-collapse: collapse;">
    <tr>
      <td style="padding: 10px;">

        <table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-collapse: collapse;">
          <tr>
            <td style="color: red; font-weight: bold; font-size: 16px;">
              XXXXXXXXXXX - TIENES %(Cantidad de cks) <span style="background: yellow;">CHEQUES</span> DISPONIBLES
            </td>
          </tr>
        </table>

        <table cellpadding="4" cellspacing="0" border="0" width="100%" style="margin-top: 10px; border-collapse: collapse;">
          <tr>
            <td style="background: red; color: white; font-weight: bold;">Código</td>
            <td>%(DG_Codigo_cliente)</td>
            <td style="background: red; color: white; font-weight: bold;">Proveedor</td>
            <td>%(DG_nombre_proveedor)</td>
          </tr>
          <tr>
            <td style="background: red; color: white; font-weight: bold;">No. Cheque</td>
            <td>%(DG_No_ck)</td>
            <td style="background: red; color: white; font-weight: bold;">Fecha</td>
            <td>%(DG_Fecha_CK)</td>
          </tr>
        </table>

        <table cellpadding="4" cellspacing="0" border="1" width="100%" style="margin-top: 15px; border-collapse: collapse; text-align: left;">
          <thead>
            <tr style="background: red; color: white; font-weight: bold;">
              <th>FACTURA</th>
              <th>NCF</th>
              <th>FECHA</th>
              <th style="text-align: right;">MONTO ORIGINAL</th>
              <th style="text-align: right;">MONTO PAGADO</th>
              <th style="text-align: right;">DESCTO APLICADO</th>
              <th style="text-align: right;">MONTO N/C</th>
              <th>NCF N/C</th>
            </tr>
          </thead>
          <tbody>
            {{#each detalles}}
            <tr>
              <td>%(DT_No_Fact)</td>
              <td>%(DT_NCF)</td>
              <td>%(DT_fecha_factura)</td>
              <td style="text-align: right;">%(DT_monto_original)</td>
              <td style="text-align: right;">%(DT_monto_pagado_en CK)</td>
              <td style="text-align: right;">%(DT_descuento_aplicado)</td>
              <td style="text-align: right;">%(DT_monto_NC)</td>
              <td>%(DT_NCF_NC)</td>
            </tr>
            {{/each}}
          </tbody>
          <tfoot>
            <tr style="font-weight: bold;">
              <td colspan="3" style="background: red; color: white;">TOTAL</td>
              <td style="text-align: right;">%(TT_total_montos_originales)</td>
              <td style="text-align: right;">%(TT_Total_pagado)</td>
              <td style="text-align: right;">%(TT_Total_descuentos)</td>
              <td colspan="2"></td>
            </tr>
          </tfoot>
        </table>

      </td>
    </tr>
  </table>

</body>
</html>

0 0
replied on April 9, 2025

Outlook and other mail clients have their own HTML interpreter, so there may be some variance between what you see in a browser and what you may see in Outlook.

0 0
replied on April 8, 2025

I'm not sure if this is the case, but the HTML template for the email should contain just the elements within the "<body>" element you typed out in your post. For clarity, I copied what section I'm referring to here:

 

  <table align="center" cellpadding="0" cellspacing="0" border="0" width="600" style="border-collapse: collapse;">
    <tr>
      <td style="padding: 10px;">

        <table cellpadding="0" cellspacing="0" border="0" width="100%" style="border-collapse: collapse;">
          <tr>
            <td style="color: red; font-weight: bold; font-size: 16px;">
              XXXXXXXXXXX - TIENES %(Cantidad de cks) <span style="background: yellow;">CHEQUES</span> DISPONIBLES
            </td>
          </tr>
        </table>

        <table cellpadding="4" cellspacing="0" border="0" width="100%" style="margin-top: 10px; border-collapse: collapse;">
          <tr>
            <td style="background: red; color: white; font-weight: bold;">Código</td>
            <td>%(DG_Codigo_cliente)</td>
            <td style="background: red; color: white; font-weight: bold;">Proveedor</td>
            <td>%(DG_nombre_proveedor)</td>
          </tr>
          <tr>
            <td style="background: red; color: white; font-weight: bold;">No. Cheque</td>
            <td>%(DG_No_ck)</td>
            <td style="background: red; color: white; font-weight: bold;">Fecha</td>
            <td>%(DG_Fecha_CK)</td>
          </tr>
        </table>

        <table cellpadding="4" cellspacing="0" border="1" width="100%" style="margin-top: 15px; border-collapse: collapse; text-align: left;">
          <thead>
            <tr style="background: red; color: white; font-weight: bold;">
              <th>FACTURA</th>
              <th>NCF</th>
              <th>FECHA</th>
              <th style="text-align: right;">MONTO ORIGINAL</th>
              <th style="text-align: right;">MONTO PAGADO</th>
              <th style="text-align: right;">DESCTO APLICADO</th>
              <th style="text-align: right;">MONTO N/C</th>
              <th>NCF N/C</th>
            </tr>
          </thead>
          <tbody>
            {{#each detalles}}
            <tr>
              <td>%(DT_No_Fact)</td>
              <td>%(DT_NCF)</td>
              <td>%(DT_fecha_factura)</td>
              <td style="text-align: right;">%(DT_monto_original)</td>
              <td style="text-align: right;">%(DT_monto_pagado_en CK)</td>
              <td style="text-align: right;">%(DT_descuento_aplicado)</td>
              <td style="text-align: right;">%(DT_monto_NC)</td>
              <td>%(DT_NCF_NC)</td>
            </tr>
            {{/each}}
          </tbody>
          <tfoot>
            <tr style="font-weight: bold;">
              <td colspan="3" style="background: red; color: white;">TOTAL</td>
              <td style="text-align: right;">%(TT_total_montos_originales)</td>
              <td style="text-align: right;">%(TT_Total_pagado)</td>
              <td style="text-align: right;">%(TT_Total_descuentos)</td>
              <td colspan="2"></td>
            </tr>
          </tfoot>
        </table>

      </td>
    </tr>
  </table>

 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.