XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
- Stylus Studio Feature Requests (1192)
-> - Proposal to Add Git Support to... (1)
-> + XML formatter option request (3)
-> - Could Pipeline input scenario ... (1)
-> + XML Traversal in XSLT Mapper (2)
-> - Email not in HTML as expected (3)
-> ->Email not in HTML as expe...
-> ->Email not in HTML as expe...
-> + My SS Open [tools]==>.[option... (3)
-> + Fonts in Stylus Studio (2)
-> - Fix the check for concurrent s... (1)
-> + Stylus is showing the error fo... (2)
-> - XML editor (1)
-> + Unable to see filename in sche... (2)
-> + Unable to connect to JVM (2)
-> - Stylus Studio forum questions (1)
-> + User Interface - X16 Enterpris... (2)
-> + Stylus Studio High DPI support (2)
-> + target xsd includes and import... (2)
-> + XML/EDIFACT Schema (3)
-> + Options to control whether BOM... (2)
-> + Snippets and/or Emmet integrat... (2)
-> + internal error accessing metho... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2016)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Bruce CantorSubject: 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&#10;" } }
</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?



UnknownClaimTESTrequestfromEETGroup.msg
resulting email

UnknownTestdataForSupport.xml
Testdata, modified

Postnext
Ivan PedruzziSubject: Email not in HTML as expected
Author: Ivan Pedruzzi
Date: 24 Feb 2022 08:45 PM
The email object takes parameter “body” as string, you are passing the DOM which gets coerced to a string $emailContent//text()

You need to serialize the HTML DOM into a string

let $emailContentAsString := ddtek:serialize($emailContent, "indent=yes")

let $email := em:Email(
$emailConfig/@mail.smtp.from,
/p1:PurchaseOrderRequest/p1:PurchaseOrder/p1:Head/p1:AdditionalAccountInfo[@Identifier='EMAIL_RECEIVER']/text(),
$emailConfig/@subject,
$emailContentAsString,
"html")




Ivan Pedruzzi
Stylus Studio Team

Posttop
Bruce CantorSubject: Email not in HTML as expected
Author: Bruce Cantor
Date: 27 Apr 2022 10:19 AM
Thank you Ivan.
It works as a charm.

/Bruce

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.