Hi All,
I thought I'd pitch in with another way that I got working, no java or other special things needed, just gel. Some may say that the way I do it below is not the greatest way to put together an HTML email, and I won't argue...
The main thing that allowed me to do this is the realisation that there's nothing stopping you from having many <![CDATA[...whatever literals you put in here...]]> to construct your final email content, so:
My email has some descriptive text,
a table in html format with a project per row (and a URL in the 'Project ID' column),
and some footer info.
The table's rows are gathered from a sql query (each row is in the variable v_row).
I've omitted lots of the gel below, but I hope that most of it makes sense...
1. Parse an xml structure, which has the 'headings' of the table in the html
<gel:parse var="v_mail_content">
<table>
<tr>
<th align="left">Project Manager</th>
<th align="left">Project ID</th>
<th align="left">Project Name</th>
<th align="right">Num Of ***</th>
<th align="right">*** Amount</th>
</tr>
</table>
</gel:parse>
2. for each row in the sql query results, construct it's URL (broken out here to avoid a very wide single line
<core:set value="https://cppm-XXXXX.ondemand.ca.com/niku/nu#action:projmgr.projectProperties" var="v_inv_url"/>
<core:set value="${v_inv_url + '&odf_view=projectCreate.subObjList.XXXX_XXXX&id=' + v_row.id}" var="v_inv_url"/>
<core:set value="${v_inv_url + '&odf_pk=' + v_row.id + '&parentObjectCode=project&odf_concrete_parent_object_code=project&odf_parent_id=' + v_row.id}" var="v_inv_url"/>
<core:set value="${v_inv_url + '&odf_cncrt_parent_id=' + v_row.id}" var="v_inv_url"/>
3. Create a html row from the data in the sql query and the constructed URL using parse
<gel:parse var="v_detail_item">
<tr>
<td align="left">${row.full_name}</td>
<td align="left"><a href="${v_inv_url}">${v_row.code}</a></td>
<td align="left">${v_row.name}</td>
<td align="right">${v_row.a_count}</td>
<td align="right">${v_row.an_amount}</td>
</tr>
</gel:parse>
4. Insert this detail item in the main table (and iterate around steps 2,3,4)
<core:catch var="gel_error">
<gel:set select="$v_mail_content/table" value="${v_detail_item}" insert="true" trim="false"/>
</core:catch>
5. Make a string version of the created table.
<core:catch var="v_exception">
<gel:set asString="true" select="$v_mail_content/table" var="v_variable"/>
</core:catch>
6. Here's the fun bit. Everything that is HTML specific jargon is encased in CDATA (many of them!), including the styling defined in the head section. Further in, I dump in the string-version of the html table/row/div constructed further up.
<gel:email
from="clarity_admin@yourcompany.com.au"
fromName="Clarity Admin"
subject="Please action XXXX in Clarity"
to="samos2@yourcompany.com.au,clarity_admin@yourcompany.com.au">
<![CDATA[<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
}
th {
text-align: left;
}
</style>
</head>
<body>
<font face="verdana" size="2">
</br></br>
<p>This email is a reminder to action the following in your Clarity projects:</p>
</br></br>
]]>
${v_variable}
<![CDATA[</br></br>]]>
Please contact <![CDATA[<a href="mailto:Clarity_Admin@yourcompany.com.au">Clarity Admin</a>]]> for any enquiries.
<![CDATA[</br></br>]]>
(Automated email sent ${v_row.mail_time})
<![CDATA[</br></font></body></html>]]>
</gel:email>
I'll try to attach a picture of the result.
Hope that helps the next person...
Sam