Copied to clipboard

Flag this post as spam?

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


  • AJS 31 posts 212 karma points
    Aug 12, 2016 @ 23:07
    AJS
    0

    How to attach a file or link to it in xslt transformed email

    Hi there,

    I need help attaching files to a xslt transformed email.

    I found an old post that referenced contour; however, this doesn't work for me.

    https://our.umbraco.org/forum/umbraco-pro/contour/64180-Umbraco-Forms-email-workflow-Full-path-of-uploaded-files-or-files-as-attachments

    <!-- Template for a File upload field -->
    <xsl:template match="*[datatype][contains(values/value, '/umbraco/plugins/umbracoContour/files/')]" mode="value">
        <a href="http://{umbraco.library:RequestServerVariables('SERVER_NAME')}{values/value}">
            <xsl:value-of select="values/value"/>
        </a>
    </xsl:template>     
    

    I needed a custom email that I configured so using the "send email" workflow isn't an option.

    Any help is much appreciated.

    Thanks,

    Amanda

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 13, 2016 @ 06:31
    Dennis Aaen
    0

    Hi Amanda,

    Try to use the following code snippet.

    <?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="/">
        <table style="border-collapse:collapse;border:1px solid black;">
              <xsl:for-each select="$records//fields/child::*">
                <xsl:sort select="@sortorder" data-type="number"/>
               <tr style="border:1px solid black;">
                      <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">
                          <strong>
                           <xsl:value-of select="./caption"/>
                          </strong>
                    </td>
                    <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">
                          <xsl:choose>
                             <xsl:when test="contains(.//value, '/umbraco/plugins/umbracoContour/files/')">
                                 <a href="http://{umbraco.library:RequestServerVariables('SERVER_NAME')}{.//value}">
                                    <xsl:value-of select="substring-after(substring-after(.//value, '/files/'), '/')"/>                      
                               </a>
                             </xsl:when>
                              <xsl:otherwise>
                                  <xsl:for-each select="./values/value">
                                      <xsl:if test="position() &gt; 1">
                                       <br />
                                      </xsl:if>
                                    <xsl:value-of select="umbraco.library:ReplaceLineBreaks(.)"/>
                               </xsl:for-each>
                              </xsl:otherwise>
                         </xsl:choose>
                      </td>
                </tr>
            </xsl:for-each>
          </table>
      </xsl:template>
    </xsl:stylesheet>
    

    Hope this helps,

    /Dennis

  • AJS 31 posts 212 karma points
    Aug 15, 2016 @ 15:06
    AJS
    0

    Hi Dennis,

    Thanks so much for your reply.

    For whatever reason, though, the file is not attaching. I am simply getting the file path as an option (not hyperlinked).

    See below email source code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><table style="border-collapse:collapse;border:1px solid black;">
    
      <tr style="border:1px solid black;">
    
        <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;"><strong>Name of your Agency</strong></td>
    
        <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">asdfasdf</td>
    
      </tr>
    
      <tr style="border:1px solid black;">
    
        <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;"><strong>Attach Invoice</strong></td>
    
        <td valign="top" style="border:1px solid black;padding:5px;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:11px;">/media/forms/upload/Form_85c9858b-a951-4add-8fb0-faf467c0b477/aaf0a9ba-8d1c-41f8-8827-8c6e00a92778/TEST_PDF.pdf</td>
    
      </tr>
    
    </table>
    

    Is it because it's referencing Contour and not Umbraco forms?

    Thanks,

    Amanda

Please Sign in or register to post replies

Write your reply to:

Draft