Copied to clipboard

Flag this post as spam?

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


  • Kim Andersen 1447 posts 2196 karma points MVP
    Jul 29, 2010 @ 22:35
    Kim Andersen
    0

    Attach image to an email through umbraco.library:SendMail

    Hi all,

    I'm using the umbraco.library:SendMail to send out an email to the owner of a website through a form on the website. It works perfectly. I use the code below:

    <xsl:template match="/">

        <xsl:variable name="settings" select="umbraco.library:GetXmlNodeById('1049')" />

        <xsl:choose>
            <xsl:when test="umbraco.library:Request('SendMail')">
                <xsl:call-template name="SendMail">
                    <xsl:with-param name="Recipients">
                        <xsl:value-of select="$settings/emailReceive"/>
                    </xsl:with-param>
                    <xsl:with-param name="Body">
                        <![CDATA[<u>Information:</u><br/><b>Navn: </b>]]><xsl:value-of select="umbraco.library:Request('navn')"/><![CDATA[<br/>]]>
                        <![CDATA[<b>Address: </b>]]><xsl:value-of select="umbraco.library:Request('adresse')"/><![CDATA[<br/>]]>
                        <![CDATA[<b>Zip code.: </b>]]><xsl:value-of select="umbraco.library:Request('zip')"/><![CDATA[<br/>]]>
                        <![CDATA[<b>City: </b>]]><xsl:value-of select="umbraco.library:Request('by')"/><![CDATA[<br/>]]>
                        <![CDATA[<b>Phone: </b>]]><xsl:value-of select="umbraco.library:Request('tlf')"/><![CDATA[<br/>]]>
                        <![CDATA[<b>E-mail: </b>]]><xsl:value-of select="umbraco.library:Request('email')"/><![CDATA[<br/>]]>
                        <![CDATA[<b>Comment: </b>]]><xsl:value-of select="umbraco.library:Request('com')"/><![CDATA[<br/>]]>
                    </xsl:with-param>
                    <xsl:with-param name="From">
                        <xsl:value-of select="$settings/emailReceive"/>
                    </xsl:with-param>
                    <xsl:with-param name="Subject">Contact from the site</xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <hr/>
                <div id="kontaktformular">
                    <form id="book" name="book" action="">
                        <input type="hidden" name="SendMail" value="t"></input>
                       
                        <label for="navn">Name</label>
                        <input type="text" name="navn" id="navn" class="required" minlength="2"/>
                        <br/>
                        <label for="alder">Age</label>
                        <input type="text" name="alder" id="alder" class="required"/>
                        <br/>
                        <label for="adresse">Address</label>
                        <input type="text" name="adresse" id="adresse" class="required"/>
                        <br/>
                        <label for="zip">Zip code</label>
                        <input type="text" name="zip" id="zip" class="required digits" minlength="4" maxlength="4"/>
                        <br/>
                        <label for="by">City</label>
                        <input type="text" name="by" id="by" class="required" minlength="2"/>
                        <br/>
                        <label for="tlf">Phone</label>
                        <input type="text" name="tlf" id="tlf" maxlength="8" minlength="8" class="required digits"/>
                        <br/>
                        <label for="email">E-mail</label>
                        <input type="text" name="email" id="email" class="required email"/>
                        <br/>
                        <label for="com">Comment</label>
                        <textarea rows="3" name="com" id="com"></textarea>
                        <br/>
                        <button type="submit" value="Send"/>
                    </form>
                </div>
            </xsl:otherwise>
        </xsl:choose>

    </xsl:template>

        <xsl:template name="SendMail">
            <xsl:param name="Recipients"></xsl:param>
            <xsl:param name="Body"></xsl:param>
            <xsl:param name="From"></xsl:param>
            <xsl:param name="Subject"></xsl:param>

            <xsl:value-of select="umbraco.library:SendMail($From, $Recipients, $Subject, $Body, 'true')"/>
            <hr/>
            <p>Thanks</p>


        </xsl:template>

    But what I'd like to do is to give the user the possibility of attaching two images to the mail. I want to create two new input fields where the user can choose an image in each of them.

    I'm pretty sure that this can't be acchieved using the extension, but I have thought of something else. Another thing that would work for me is the following:

    When the user clicks the send-button, the two selected images will be uploaded into the media-section of umbraco, and in the mail-body of the e-mail there could then be two links to the two files in the media section. Is this easier to do?

    This will probably need some .NET, but unfortunatelly I can't code in .NET my self. But if some of you guys have got a snippet or knows how this can be done in .NET/XSLT I would really love to see it. Any help will be greatly appreciated.

    Thanks in advance!

    /Kim A

  • 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