Copied to clipboard

Flag this post as spam?

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


  • Greg Fyans 140 posts 342 karma points
    Aug 18, 2011 @ 15:24
    Greg Fyans
    0

    XSLT transformed email - umbraco.library:SendEmail custom From address?

    Hello,

    I'm trying to send an email from the Send XSLT transformed email workflow in Contour and pull the From address from the form values.

    I have it sending the email, but I'm not sure how to pull the value I want. Here is my XSLT:

    <?xml version="1.0" encoding="utf-8"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="xsl msxsl user umbraco.library">

      <xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" cdata-section-elements="script style" indent="yes" encoding="utf-8"/>
      <xsl:param name="records" />
      <xsl:template match="/">
    <xsl:variable name="bodyText">
    <xsl:for-each select="$records//fields/child::*">
    <strong><xsl:value-of select="./caption" />: </strong><xsl:value-of select=".//value" />&lt;br /&gt;&lt;br /&gt;
    </xsl:for-each>
    </xsl:variable>
    <xsl:value-of select="$bodyText"/>    
        <xsl:variable name="fromEmail" select="$records//fields/emailaddress"/>
        <xsl:value-of select="umbraco.library:SendMail($fromEmail, '[email protected]', 'Subject', $bodyText, 'true')"/>
      </xsl:template>
    </xsl:stylesheet>

    The email does send, but the fromEmail value comes through as:

    "40082670-9ce5-4192-99ee-0471be99569a0a13ae86-f0d0-4329-9365-27eb646891f7Email addressStringgreg"@domain.com

    Any suggestions?

    Thanks,
    Greg.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 15:41
    Tom Fulton
    0

    Hi Greg,

    The built-in Contour workflows automatically send From the address defined in umbracoSettings.config.  In order to change the from address you'd need to create your own custom workflow.  The Contour Contrib has workflows that allow you to set the "Reply To" address but not the actual "From" address.

    -Tom

  • Jacob Jensen 40 posts 60 karma points
    Aug 18, 2011 @ 15:45
    Jacob Jensen
    0

    Are u sure : $records//fields/emailaddress only gets an email, it looks like it has childnodes.

    What's in the mail when u take this mailbody:

    <xsl:variable name="bodyText">
    <xsl:for-each select="$records//fields/emailaddress">
    <strong><xsl:value-of select="./name()" />: </strong><xsl:value-of select="." />&lt;br /&gt;&lt;br /&gt;
    </xsl:for-each>
    </xsl:variable>

     

    /J

  • Greg Fyans 140 posts 342 karma points
    Aug 18, 2011 @ 15:46
    Greg Fyans
    0

    Hi Tom,

    I tried the Contour Contrib workflow, but I got an "Object reference" error and no additional details in the log, so I abandoned that and went with the XSLT transformed email:

    http://our.umbraco.org/forum/umbraco-pro/contour/15723-Sending-email-to-certain-email-address-dependent-on-selection-in-form

    Like I said, I almost have it, the email does send, it's just the From address value that's incorrect. My xpath is wrong, I'm just not sure how to pull the value and not the whole section.

     

     

     

    @Jacob, 2 minutes, let me try that.

    Cheers,
    Greg.

  • Jacob Jensen 40 posts 60 karma points
    Aug 18, 2011 @ 15:46
    Jacob Jensen
    0

    foreach - > $records//fields/emailaddress/*

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 15:52
    Tom Fulton
    0

    Oh sorry, I didn't realize you were sending the email from the actual XSLT file.  Never thought of that :)

    I think to get the actual value of a field you want to pull the value element:

    <xsl:variable name="fromEmail" select="$records//fields/emailaddress//value"/>

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 18, 2011 @ 15:57
    Fuji Kusaka
    0

    You could try this, but when adding the caption email address remember to put it correctly as its case sensitive

    <xsl:value-of select="$records//fields/child::* [caption = 'emailaddress']//value"/>

    //fuji

  • Greg Fyans 140 posts 342 karma points
    Aug 18, 2011 @ 16:07
    Greg Fyans
    0

    Excellent.

    Cheers for your help guys, Fuji's suggestion works for me. I thought Tom's would as well as "$records//fields/emailaddress" gets me something, but unfortunately it didn't.

    <xsl:variable name="fromEmail" select="$records//fields/child::* [caption = 'Email address']//value" />
    <xsl:value-of select="umbraco.library:SendMail($fromEmail, '[email protected]', 'Subject', $bodyText, 'true')"/>

    Cheers again,
    Greg.

Please Sign in or register to post replies

Write your reply to:

Draft