Email notification - html formatting

I tried to use Template notification for sending notification from work queue.

When I put <html> tag in MessageBody element I expected email to allow html formatting. More so I also expected it will have ContentType of text/html.

Unfortunately ContetnType of delivered email is text/plain and no html formatting is applied. It seems to be ignored completely.

How can I format email body using html tags?

Example of my template:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:AS="http://schema.advantages.cz/AsapFunctions"
	xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date">

	<xsl:template match="ROOT">
		<ROOT>
			<xsl:apply-templates select="WorkQueueEntry"/>
		</ROOT>
	</xsl:template>

	<xsl:template match="WorkQueueEntry">
		<xsl:variable name="cRCPT" select="AS:LookupList('a6752be1-536f-4fad-a1f8-826fe12ba93a','BusinessPartnerCommunicationChannel_parBusinessPartnerId',@refId)"/>
		<xsl:variable name="RCPTEmail">
			<xsl:for-each select="$cRCPT/list/item"><xsl:value-of select="AS:iif(string-length(@Text)!=0,concat(@Text,';'),concat(@Name,' (',@Code,')'))"/></xsl:for-each>
		</xsl:variable>

			<MailParameters
				Subject="{concat('UPOMÍNKA ze dne ',date:format-date(date:date-time(),'dd.MM.yyyy'))}"
				rcptMail="{$RCPTEmail}"
MailWQ="{'EMAIL'}"
			>
			<Body>
<html><body>
Vážení rodiče a žáci,


na Vašem DM účtu ID - <xsl:value-of select="@Code" /> - <xsl:value-of select="@FirstName" />, <xsl:value-of select="@Name" /> evidujeme k dnešnímu dni nedostatečný zůstatek ve výši <xsl:value-of select="format-number(@Limit - @PaymentBalance,'#.00')" /> Kč. Minimální výše zůstatku je dle vašich služeb stanovena na <xsl:value-of select="format-number(@Limit,'#.00')" /> Kč.

Tato upomínka byla vygenerována systémem automaticky.

Po uplynutí 5. pracovních dnů od vygenerování této upomínky proběhne kontrola stavu zůstatku vašeho DM účtu. V případě, že váš zůstatek bude stále podlimitní, bude vám účtováno smluvní penále ve výši 200 Kč.

<b>PLATEBNÍ ÚDAJE PRO DOBITÍ KREDITU:</b>

Číslo účtu: 1
Variabilní symbol: <xsl:value-of select="@Code" />
IBAN: xxxx
SWIFT: zzzz

Na tento e-mail nereagujte.

Máte-li dotazy týkající se Vašeho zůstatku nebo této upomínky, obraťte se na referenta agendy žáků e-mail: <a href="mailto:jan.novak@firma.cz">jan.novak@firma.cz</a>.

S pozdravem

<span style="font-weight: bold;">firma XY</span>
</body></html>
			</Body>
			</MailParameters>
	</xsl:template>
</xsl:stylesheet>

If you are talking about notification templates used for the work queue notifications, below is an example of what works.

First issue is that the entity (element) used as the source of data is OrigamNotification. Subject is defined as an attribute, body as an element.

image

Second issue is that you are inside a transformation, so all tags must be escaped, using &lt; for < and &gt; for >.

Also the recipient email is defined on the Notification Recipients tab of the work queue screen.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:AS="http://schema.advantages.cz/AsapFunctions"
xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date">

<xsl:param name="RecipientRow"/>
<xsl:param name="WorkQueueRow"/>

<!-- common variables -->
<xsl:include href="model://d296007c-80db-4bd3-aeb7-84d2b0504ad2"/>

<xsl:template match="ROOT">
    <ROOT>
          <OrigamNotification>
                 <xsl:attribute name="Subject">
                      <xsl:value-of select="concat($lessorName, ' password reset request')"/>
                 </xsl:attribute>
                 <Body>&lt;html&gt;
Hello <xsl:value-of select="/ROOT/BusinessPartner/UserName"/>,
&lt;br&gt;
&lt;br&gt;
You, or a third party recently requested to reset the password for user <xsl:value-of select="/ROOT/BusinessPartner/UserName"/>.
&lt;br&gt;
&lt;br&gt;
In case you didn't ask for resetting your password yourself, you can ignore this email. Your account data will remain protected by your current password. Furthermore the password reset link can only be used once within <xsl:value-of select="$WorkQueueRow/row/@TokenValidityHours"/> hours.
&lt;br&gt;
&lt;br&gt;
&lt;a href="<xsl:value-of select="$link"/>"&gt;Click here&lt;/a&gt; to choose a new password
&lt;br&gt;
&lt;br&gt;
Your <xsl:value-of select="$lessorName"/> Team
&lt;br&gt;
&lt;br&gt;
<xsl:if test="$isLessorGiven">
<xsl:value-of select="$lessorName"/> 
</xsl:if>
&lt;/html&gt;</Body>
          </OrigamNotification>
     </ROOT>
</xsl:template>
</xsl:stylesheet>
1 Like

Or if you are trying to use SendMail Method as @zcapkova pointed out the main issue would be that the <MessageBody> element should be escaped. But you have a tag <Body> so it is not clear what form of e-mail method you are using.

I acctually generate email using Mail DataStructure and then send it via WorkQueue by Send command of Mail WorkQueueClass.

Mine element content is actualy inserter into element content in the transfrormation called _simpleMail that I adjusted this way

  <ROOT>
  	<Mail 
  		Id="{AS:GenerateId()}"
  		Subject="{$subject}"
  		DateSent="{date:date-time()}"
  		CC="{$recipientCCEmail}"
  		BCC="{$recipientBCCEmail}"
  		>
  		
  		<Sender><xsl:value-of select="$sender"/></Sender>
  		<Recipient><xsl:value-of select="AS:isnull($recipientEmail,'foo')"/></Recipient>
  		<MessageBody>&lt;html&gt;<xsl:value-of select="$body"/>&lt;/html&gt;</MessageBody>
  		
  		<xsl:if test="string($attachment)">
  			<MailAttachment>
  				<Id><xsl:value-of select="AS:GenerateId()"/></Id>
  				<Data><xsl:value-of select="$attachment"/></Data>
  				<FileName><xsl:value-of select="$attachmentName"/></FileName>
  			</MailAttachment>
  		</xsl:if>

So maybe I use wrong procedure or method.

Thank you. After some adjustment I manage to format email as HTML.

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