|
next
|
Subject: Email not in HTML as expected Author: Bruce Cantor Date: 23 Feb 2022 12:56 PM
|
Hi
Can somebody give me a hint to what I need to do to get this code to work?
I am trying to let xquery send an email in formattet HTML, but all the tags are stripped away when sending, so the receiver only receives a mail in text format.
Code:
declare namespace es = "ddtekjava:com.ivitechnologies.pipeline.ext.email.EmailSession";
declare namespace em = "ddtekjava:com.ivitechnologies.pipeline.ext.email.Email";
declare namespace p1 = "http://generic.xml.eetgroup.com";
declare function es:EmailSession($settings as element(*, xs:untyped)) as ddtek:javaObject external;
declare function es:sendEmail($this as ddtek:javaObject, $email as ddtek:javaObject) as xs:boolean external;
declare function em:Email($sender as xs:string,
$recipients as xs:string,
$subject as xs:string,
$body as xs:string,
$message_mime_type as xs:string
) as ddtek:javaObject external;
declare function em:setHeader($name as xs:string, $value as xs:string) as xs:string external;
(:-:)
declare variable $now := ddtek:format-dateTime(fn:current-dateTime(), '[Y0001][M01][D01][H01][m01][s01]');
declare variable $fileName := concat("TestClaim.", $now, '.html');
declare variable $config := doc(resolve-uri("../Config/config.xml", fn:static-base-uri()));
declare variable $archiveURI := $config/config/Epson/archiveURI;
declare variable $emailConfig := $config/config/Epson/email;
(:-:)
let $session := es:EmailSession($emailConfig)
let $emailContent :=
<div style="text-align: none;">
{
if(string(/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Test = true())) then
<div style="text-align: none;">
{ text { "This is a Test document " } }
</div>
else
<div style="text-align: none;">
</div>
}
<br/>
{ text { "Dear " } }
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'Supplier']/p1:Name1)) }
<br/>
<br/>
{ text { "We would like to claim quotations on :" } }
<br/>
<br/>
{ text { "Order No:" } }
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:OrderNo)) }
<br/>
<br/>
{
for $PurchaseOrderLine in /p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:PurchaseOrderLines/p1:PurchaseOrderLine
return
<div>
<div style="text-align: none;">
{
if(string(($PurchaseOrderLine/p1:BidNo)[1])) then
<div style="text-align: none;">
{ text { "Line no: " } }
{ string(($PurchaseOrderLine/p1:ReferenceNo)[1]) }
{ text { ", Item no:" } }
{ string(($PurchaseOrderLine/p1:VendorsItemNo)[1]) }
{ text { ", Quote:" } }
{ string(($PurchaseOrderLine/p1:BidNo)[1]) }
</div>
else
<div style="text-align: none;">
</div>
}
</div>
</div>
}
<br/>
{ text { "Best Regards" } }
<br/>
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'SellTo']/p1:Name1)) }
<br/>
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'SellTo']/p1:Address1)) }
<br/>
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'SellTo']/p1:PostCode)) }
<br/>
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'SellTo']/p1:City)) }
<br/>
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'SellTo']/p1:Country)) }
<br/>
<br/>
{ text { "Att: " } }
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'SellTo']/p1:Att)) }
{ text { ", " } }
{ string((/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:Address[@Type = 'SellTo']/p1:Email)) }
</div>
let $email := em:Email($emailConfig/@mail.smtp.from, /p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:AdditionalAccountInfo[@Identifier='EMAIL_RECEIVER']/text(),
$emailConfig/@subject,
$emailContent,
"html")
return es:sendEmail($session, $email)
The resulting email is attached and as it shows all tags have been stripped away and only the unformatted text i left.
What am I missing in the code / how do I enable the html formatting?
ClaimTESTrequestfromEETGroup.msg resulting email
TestdataForSupport.xml Testdata, modified
|
|
|
|