Problems with displaying an html table within an Email Template

Hello,
my requirement is to send a report by email containing a table with data.
This data is read from a database and transformed into a table in html format.
I basically pass a variable that already contains the formatted table, but the email I receive shows not the table in graphic format but the html code.

Which IIQ version are you inquiring about?

Version 8.3p3

Please share any images or screenshots, if relevant.

I have also tried using VTL to generate an html table but I get the same result. Does anyone have any idea how I can solve this?
Thank you very much for your possible help.

@adolfotrinca -

Could you share the email template here.

Also, just for your information, any message body written as HTML must be contained within a CDATA section. Kindly validate.

<Body><![CDATA[

<html>

<body style="background:#FFF;margin:0;padding:0;text-align:left;">

<p style="margin:20px 0 0;padding:0;color:#333;font:bold 10pt Arial;line-height:15pt;">$!{workItem.owner.firstname},</p>

<p style="margin:0 0 20px;padding:0;color:#333;font:normal 10pt Arial;line-height:15pt;">As part of our periodic compliance efforts, you are responsible for certifying the access your employees have to enterprise applications. </p>

<p style="margin:0;padding:0;color:#333;font:normal 10pt Arial;line-height:15pt;">A specific access certification is named <b>$!{workItemName}</b> has been created for you, and is due on <strong>$spTools.formatDate( $certification.expiration,3,3)</strong>. <a href="http://localhost:8080/identityiq/manage/certification/entityList.jsf?certificationId=$!{certification.id}">Click here to get started on this task.</a></p>

</body>
</html>
]]> </Body>

Thank you!

  1. How you’re triggering that email? via code or by OOTB?
  2. If email is triggering from code are you passing input argument correctly?
  3. Validate Email. I can see that header and body tag has “<” and table tag has “<”. Remember Email templates is written in XML file. So you need to convert “<” into “<” or use CDATA as mentioned by @officialamitguptaa .

First of all, thank you for your reply.
This is the email template:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE EmailTemplate PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<EmailTemplate created="1729593466437" id="0a01295991e71f468192b3cdde4525c4" modified="1729678896789" name="Cap00">
  <Body>
    &lt;html lang="en">
    &lt;head>
        &lt;meta charset="UTF-8">
        &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
        &lt;title>Cap00&lt;/title>
    &lt;/head>
    &lt;body>
        &lt;div style="font-size: 12px">Gentile Supporto,&lt;br />
        sono stati rilevati i seguenti account:&lt;br />
        &lt;/div>
        &lt;br />&lt;br />
        &lt;div>

        $(htmlTable)
    
        &lt;/div>
    &lt;/body>
    &lt;/html>
 
  </Body>
  <Signature>
    <Inputs>
      <Argument name="htmlTable" type="String">
        <Description>Report</Description>
      </Argument>
    </Inputs>
  </Signature>
  <Subject>Cap00</Subject>
</EmailTemplate>

I have of course tried to insert the CDATA in the template definition in xml, but every time I save on SailPoint it it escapes the special characters and when I reopen the xml I find it like this.

Ciao, thank you too for your kind reply.

First answer:
The email is sent via a Rule that reads information from a db and formats it in html.
The idea was to send the email template the data ready to be displayed.
Have you ever had to send an email with data extracted from an oracle table for example? If so, how did you do it?

Second answer:
Yes, I checked and the rule sends the parameters that way:

    EmailTemplate template = context.getObjectByName(EmailTemplate.class,"Cap00");

    Map mailArgs = new HashMap();

    mailArgs.put("htmlTable", htmlTable);

    String toAddress = "[email protected]";

    EmailOptions options = new EmailOptions(toAddress, mailArgs);
    options.setSendImmediate(true);

    context.sendEmailNotification(template, options);

Third answer:
I fixed that part, it is now correct, only the part of the html table passed to the emailtemplate still has the problem.
What it seems to me is that although I construct the string in this way:

htmlTable.append("&lt;div style='overflow-x:auto;'>\n");

In the end the htmlTable variable contains invalid characters, here are the lines I print in the catalina.log

<div style='overflow-x:auto;'>
<table border='1' style='width: 100%; border-collapse: collapse;'>
  <thead>
    <tr>
      <th style='padding: 8px; text-align: left; background-color: #f2f2f2;'>IdentitĂ </th>
      <th style='padding: 8px; text-align: left; background-color: #f2f2f2;'>Attributi_Aggregati</th>
      <th style='padding: 8px; text-align: left; background-color: #f2f2f2;'>Applicazione</th>
      <th style='padding: 8px; text-align: left; background-color: #f2f2f2;'>Numero_Valori</th>
      <th style='padding: 8px; text-align: left; background-color: #f2f2f2;'>Valori_Aggregati</th>
      <th style='padding: 8px; text-align: left; background-color: #f2f2f2;'>Account</th>
      <th style='padding: 8px; text-align: left; background-color: #f2f2f2;'>iiq_disabled</th>
    </tr>
  </thead>

So the problem could be that I pass a varible to the template that contains characters that are not allowed?

I haven’t tried fetch the data from DB and passing to email template. My is guess the parameter that you’re passing is taking as a string. Can you try below code?

#include($htmlTable)

For reference

Bye,
the include does not work, that is for importing files into the template. If I apply the change you suggested, I get this error:

Caused by: org.apache.bsf.BSFException: The application script threw an exception: sailpoint.tools.GeneralException: Unable to find resource '<div style='overflow-x:auto;'>

But thanks to the link you sent me I found the solution, instead of using the include you have to use the evaluate, now it works, I just have to adjust the aesthetics a bit.

#evaluate($htmlTable)

So this is the correct template:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE EmailTemplate PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<EmailTemplate created="1729593466437" id="0a01295991e71f468192b3cdde4525c4" modified="1729678896789" name="Cap00">
  <Body>
    &lt;html lang="en">
    &lt;head>
        &lt;meta charset="UTF-8">
        &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
        &lt;title>Cap00&lt;/title>
    &lt;/head>
    &lt;body>
        &lt;div style="font-size: 12px">Gentile Supporto,&lt;br />
        sono stati rilevati i seguenti account:&lt;br />
        &lt;/div>
        &lt;br />&lt;br />
        &lt;div>

        #evaluate($htmlTable)
    
        &lt;/div>
    &lt;/body>
    &lt;/html>
 
  </Body>
  <Signature>
    <Inputs>
      <Argument name="htmlTable" type="String">
        <Description>Report</Description>
      </Argument>
    </Inputs>
  </Signature>
  <Subject>Cap00</Subject>
</EmailTemplate>
2 Likes

Cool, Glad you find the solution

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.