Click to See Complete Forum and Search --> : XML, XSL; passing "é", "è", "à" to OUTLOOK with Mailto:


Reimo
12-02-2008, 06:45 AM
Hi,

I'm having an encoding problem in IE6 and Outlook.
In the XML I have To, CC, Subject and Body elements which are turned into a Mailto link by the XSL.
This creates a HTML page with the link, and when I click on it, it opens a mail template in Outlook.

Only problem is that some mails must be in French, and so "é", "è" and "à" for example don't show up properly in the Outlook message, or even in IE6 if I try to display it.

For example, I get " pièce " in stead of "pièce".

I wrote the xml and xsl in notepad - ASCII - and it creates an error in IE6 if I save the xml or xsl as UFT-8. (I had encoding="UFT-8" in the xsl before, but nothing changed when I modified it to ISO...)

Anybody have an idea of what the problem could be ?
Below is the xml and xsl code.



XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="contacts.xsl"?>
<messages>
<contact id="Daily MIS">
<to>test@test.com</to>
<subject>Daily Report</subject>
<body>
Bonjour,%0A%0A
Vous trouverez en pièce jointe le report pour aujourd'hui.%0A%0A
Les numéros dans les cellules correspondent à une description détaillée dans le second onglet.%0A%0A
Cordialement,%0A%0A
</body>
</contact>

</messages>


XSL:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="/">
<html>
<body>

<h2>SEND MAIL TO:</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Contact</th>
<th align="left">Create Mail</th>
</tr>

<xsl:for-each select="messages/contact">
<tr>
<td>
<A>
<xsl:attribute name="href">mailto:
<xsl:apply-templates select="to"/>
<xsl:text>&amp;CC=</xsl:text>
<xsl:apply-templates select="cc"/>
<xsl:text>?Subject=</xsl:text>
<xsl:value-of select="subject"/>
<xsl:text>&amp;body=</xsl:text>
<xsl:value-of select="body"/>
</xsl:attribute>
<xsl:value-of select="@id"/>
</A>
</td>
<td>
<xsl:value-of select="subject"/>
</td>
</tr>
</xsl:for-each>


</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>




Thanks,

rpgfan3233
12-02-2008, 12:09 PM
AFAIK, there isn't a way around this issue. I've tried changing the encoding settings in Outlook, adding byte order marks (BOMs), using various output encodings, and even using numeric character references. They all failed, but perhaps I missed something.

Unless you're transferring control to another Web page, my recommendation is to avoid using characters like these in attributes as such things don't seem to work well. People have even had problems with simply copying from Microsoft Word and pasting into Microsoft Outlook -- something that shouldn't happen. It's an unfortunate flaw, and there isn't much you can do about it without turning it into a URL-encoded string (e.g. "%E8" instead of 'è'). I'm not sure I mean, you could technically use it in a form as long as it stays within the Web page. If the escape-uri() XPath function worked in most browsers, you could do it easily then... Unfortunately, that's not the case. :(

lightng
12-13-2008, 07:42 PM
I wrote the xml and xsl in notepad - ASCII - and it creates an error in IE6 if I save the xml or xsl as UFT-8. (I had encoding="UFT-8" in the xsl before, but nothing changed when I modified it to ISO...)

Dont you mean UTF-8 or is that a typo? :)

Theres a gotcha with using encoding = "UTF-8". Its not sufficient for the file to just have this in the preprocessor but the file itself also has to be saved in UTF-8 format. Notepad in the "save as" options (i think) will allow you to choose what format to save it in. The default in notepad is probably ANSI but dont quote me as I dont use Windows, I'm an OS X fan.

Stephen Philbin
12-14-2008, 04:23 PM
...but the file itself also has to be saved in UTF-8 format...

It is. That's the problem. The non-ASCII compatible characters are being encoded in the UTF-8 format, but the sequence of bytes used to represent these characters in the UTF-8 format will display as "è" etc. when they are displayed with an ISO-8859-1 (or similair) encoding.

This is a bit of a long-shot, but have you tried ensuring that the file that contains the mailto link is being served with a HTTP header the specifies UTF-8 as the document's encoding format? I'm thinking that maybe IE will be telling Outlook which encoding to use based on the HTTP header of the document containing the link. It may even be from the meta tag instead of the HTTP header.