Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonas Eriksson 930 posts 1825 karma points
    Dec 17, 2009 @ 08:17
    Jonas Eriksson
    0

    How to keep html-tags in a variable? (For use with Sendmail)

    Hi!

    I have a problem sending html-formatted email with Sendmail.

    umbraco.library:SendMail($senderEmailAddress, $administratorEmailAddress, $subject, $messageFormatted, true())

    The $messageFormatted is a variable build like this:

    <xsl:variable name="messageFormatted">
    <h1>Message header</h1>
    <p>Message body</p>
    </xsl:variable>

    The email is sent with no html-tags, the tags are removed from the variable in some step, I don't know how to keep them. :-o (If I put a string with tags instead of the variable the html-tags are kept, for example

    umbraco.library:SendMail($senderEmailAddress, $administratorEmailAddress, $subject, '&lt;h1&gt;Header&lt;/h1&gt;', true())

    )

    So I wonder how to keep the html-tags in my variable. CData?

    Thanks!

  • Jonas Eriksson 930 posts 1825 karma points
    Dec 17, 2009 @ 08:24
    Jonas Eriksson
    0

    I noticed that this approach works:

    <xsl:variable name="messageFormatted">
    <![CDATA[
    <h1>Message header</h1>
    <p>Message body</p>
    ]]>
    </xsl:variable>

    But ... I have lots of variables in my message (which could not be used in CData) and using CData would mean a very messy code.

    <xsl:variable name="messageFormatted">
    <![CDATA[
    <h1>Message header</h1>
    <xsl:value-of select="$someVariable"/>
    <p>Message body</p>
    <xsl:value-of select="$someOtherVariable"/>
    ]]>
    </xsl:variable>
  • Jonas Eriksson 930 posts 1825 karma points
    Dec 17, 2009 @ 08:35
    Jonas Eriksson
    1

    Well, ok, it's not sooo messy, and it work's so I'll use this for now :-)

    <xsl:variable name="messageFormatted">
    <![CDATA[<h1>Message header</h1>]]>
    <xsl:value-of select="$someVariable"/>
    <![CDATA[<p>Message body</p>]]>
    <xsl:value-of select="$someOtherVariable"/>
    </xsl:variable>
  • Jukka-Pekka Keisala 90 posts 226 karma points
    Dec 27, 2009 @ 11:17
    Jukka-Pekka Keisala
    0

    I saw solution somewhere while ago. I don't have orginal URL but code works. Just add xmlns:msxsl="urn:schemas-microsoft-com:xslt" and xmlns:csharp="urn:csharp-com:xslt" namespaces.

    Put function in XSLT

     

        <msxsl:script language="C#" implements-prefix="csharp">

            <![CDATA[

        public static string getText(XPathNavigator nodes)

        {

            return nodes.OuterXml;

        }

        ]]>

        </msxsl:script>

     

     

    Then call SendMail with the getText function

    csharp:getText($messageFormatted)

     

  • Jonas Eriksson 930 posts 1825 karma points
    Dec 30, 2009 @ 19:10
    Jonas Eriksson
    0

    Jukka-Pekka : ok, makes sense, thanks. Looks like a function that should be conventient to have in a helper xslt-extension-dll.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies