Hi Kaj 

I have another solution for you (Seems as if we were both working on the same 
stuff) ;)

For sending Emails I use the SendmailTransformer. When starting work on this I 
had to realize that there is very little information available on the sendmail 
transformer ... here the Pipelines, Flowscript and XSLTs:

<map:transformers default="xslt">
        ...
        <map:transformer logger="sitemap.transformer.sendmail" name="sendmail" 
src="org.apache.cocoon.mail.transformation.SendMailTransformer"/>
        ...
</map:transformers>
...
<map:pipeline>
        <map:match pattern="send-email">
                <map:generate src="module:flow-attr:cart" /> 
                <map:transform src="stylesheets/cart2email.xsl">
                        <map:parameter name="cartTotal" 
value="{flow-attr:cartTotal}"/>
                        <map:parameter name="shippingCosts" 
value="{flow-attr:shippingCosts}"/>
                </map:transform>
                <map:transform type="sendmail" /> 
                <map:transform src="stylesheets/email2html.xsl" /> 
                <map:transform src="stylesheets/master.xsl">
                        <map:parameter name="single-page" value="true"/>
                </map:transform>
                <map:serialize/>
        </map:match>
</map:pipeline>

The cart2email.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
        <xsl:param name="cartTotal" select="1234.56"/>
        <xsl:param name="shippingCosts" select="342.35"/>
        
        <xsl:template match="/">
                <document 
xmlns:email="http://apache.org/cocoon/transformation/sendmail";>
                        <email:sendmail>
                                
<email:smtphost>mail.yoursmpthost.de</email:smtphost>
                                <email:from>[EMAIL PROTECTED]</email:from>
                                <email:to>[EMAIL PROTECTED]</email:to>
                                <email:to><xsl:value-of 
select="/cart/billingAddress/@email"/></email:to>
                                <email:subject>Ihre Bestellung auf 
www.CoolCocoonShop.de</email:subject>
                                <email:body><![CDATA[
                                        <p>Hiermit bestätigen wir den Erhalt 
Ihrer Bestellung.</p>
                                        
                                        <p>Es wurden folgende Produkte bestellt:
                                        <table>
                                                <tr>
                                                        <th>Bezeichung:</th>
                                                        <th>Menge:</th>
                                                        <th>Einzelpreis:</th>
                                                        <th>Gesamtpreis:</th>
                                                </tr>]]>
                                                <xsl:for-each 
select="/cart/cartContent/content/product">
                                                        <![CDATA[<tr>
                                                                
<td>]]><xsl:value-of select="@product"/><![CDATA[</td>
                                                                <td 
style="text-align:right;">]]><xsl:value-of select="format-number(@count, 
'#0')"/><![CDATA[</td>
                                                                <td 
style="text-align:right;">]]><xsl:value-of select="format-number(@price, 
'#0.00')"/><![CDATA[€</td>
                                                                <td 
style="text-align:right;">]]><xsl:value-of select="format-number(number(@count) 
* number(@price), '#0.00')"/><![CDATA[€</td>
                                                        </tr>]]>
                                                </xsl:for-each>
                                                <![CDATA[<tr>
                                                        <td>Gesamt 
Bestellwert:</td>
                                                        <td colspan="3" 
style="text-align:right;">]]><xsl:value-of select="format-number($cartTotal, 
'####0.00')"/><![CDATA[€</td>
                                                </tr>
                                                <tr>
                                                        <td>16% MWSt.:</td>
                                                        <td colspan="3" 
style="text-align:right;">]]><xsl:value-of 
select="format-number((number($cartTotal) div 1.16) * 0.16, 
'#####0.00')"/><![CDATA[€</td>
                                                </tr>
                                                <tr>
                                                        <td>Porto & 
Verpackung:</td>
                                                        <td colspan="3" 
style="text-align:right;">]]><xsl:value-of 
select="format-number($shippingCosts, '#####0.00')"/><![CDATA[€</td>
                                                </tr>
                                                <tr>
                                                        <td>Gesamtpreis (incl. 
16% MWSt.):</td>
                                                        <td colspan="3" 
style="text-align:right;">]]><xsl:value-of select="format-number($cartTotal + 
$shippingCosts, '#####0.00')"/><![CDATA[€</td>
                                                </tr>
                                        </table>
                                        </p>
                                        
                                        <p>Es wurde die folgende 
Rechnungsanschrift angegeben:<br/>]]>
                                                <xsl:value-of 
select="/cart/billingAddress/@title"/> <xsl:value-of 
select="/cart/billingAddress/@firstName"/> <xsl:value-of 
select="/cart/billingAddress/@lastName"/><![CDATA[<br/>]]>
                                                <xsl:value-of 
select="/cart/billingAddress/@company"/><![CDATA[<br/>]]>
                                                <xsl:value-of 
select="/cart/billingAddress/@street"/><![CDATA[<br/>]]>
                                                <xsl:value-of 
select="/cart/billingAddress/@zip"/> <xsl:value-of 
select="/cart/billingAddress/@city"/><![CDATA[<br/>]]>
                                                <xsl:value-of 
select="/cart/billingAddress/@country"/><![CDATA[<br/>]]>
                                                Telefon:        <xsl:value-of 
select="/cart/billingAddress/@phone"/><![CDATA[<br/>]]>
                                                Email:  <xsl:value-of 
select="/cart/billingAddress/@email"/><![CDATA[<br/>
                                        </p>

                                        <p>]]>
                                                <xsl:choose>
                                                        <xsl:when 
test="/cart/billingAddress/@differentShippingAddress = 'true'">
                                                                <![CDATA[Die 
Lieferung der Ware erfolgt an folgende, von der Rechnungsanschrift abweichenden 
Lieferanschrift:<br/>]]>
                                                                <xsl:value-of 
select="/cart/shippingAddress/@title"/> <xsl:value-of 
select="/cart/shippingAddress/@firstName"/> <xsl:value-of 
select="/cart/shippingAddress/@lastName"/><![CDATA[<br/>]]>
                                                                <xsl:value-of 
select="/cart/shippingAddress/@company"/><![CDATA[<br/>]]>
                                                                <xsl:value-of 
select="/cart/shippingAddress/@street"/><![CDATA[<br/>]]>
                                                                <xsl:value-of 
select="/cart/shippingAddress/@zip"/> <xsl:value-of 
select="/cart/shippingAddress/@city"/><![CDATA[<br/>]]>
                                                                <xsl:value-of 
select="/cart/shippingAddress/@country"/><![CDATA[<br/>]]>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                                <![CDATA[Die 
Lieferung der Ware erfolgt an die oben genannte Adresse.<br/>]]>
                                                        </xsl:otherwise>
                                                </xsl:choose>
                                                <xsl:if 
test="/cart/cartContent/alternateFormat = 'yes'">
                                                        <![CDATA[<br/>Falls A7 
zur Zeit nicht lieferbar ist, bin ich damit Einverstanden zum gleichen Preis 
das entsprechende Bild im größeren Format DIN A6 zu erhalten.<br/>]]>
                                                </xsl:if>
                                                <xsl:if 
test="string-length(/cart/notes) &gt; 0">
                                                        <![CDATA[<br/>Es wurden 
folgende Hinweise angegeben:<br/>]]>
                                                        <xsl:value-of 
select="/cart/notes"/>
                                                </xsl:if>
                                        <![CDATA[</p>                   
                        
                                        <p>Bei dieser Mail handelt es sich um 
die Bestätigung, dass Ihre Bestellung entgegen genommen wurde.</p>
                                        <p>Vielen Dank für Ihren Auftrag.</p>
                                        <p>Mit freundlichen Grüßen,<br/>
                                                Ihr Espirit-Team
                                        </p>]]>
                                </email:body>
                        </email:sendmail>
                </document>
        </xsl:template>
</xsl:stylesheet>

Now please don't crucify me for not translating the code ;)

And last but not least the Flowscript:

cocoon.sendPage("send-email", {cart: 
Packages.org.apache.axis.utils.XMLUtils.DocumentToString(cart).getBytes("UTF-8"),
 cartTotal:calculateCartTotal(), shippingCosts:calculateShippingCosts()});

I have to mention, that my cart is a plain old W3C Dom object. I sort of have 
to serialize it, if I want to add it ... don't really know why, but it works ;)

Hope I could help.

Chris

-----Ursprüngliche Nachricht-----
Von: Kaj Kandler [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 18. Mai 2006 03:30
An: [email protected]
Betreff: Sending E-Mail with CForms

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,
has anybody an example "how to send e-mail" from Flow Script?

I do have set up a cocoon form with template and a flow script. I'd like
to peak at someones code for sending an e-mail.

I have found samples using <action> and logicsheets. But I can't find
how to combine that with my CForm.

All help appreciated

Kaj
- --
[EMAIL PROTECTED]

- -----------------------------------------------------
|  We produce animated software manuals that click  |
- -----------------------------------------------------
 Conficio
 http://www.conficio.com/
 P.O.Box 761062,  Melrose,
 MA 02176

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFEa84xRDUvrJRNjTARAlINAKCb8SBfTcR44jhyfandQFd5gKQNbACdGRGy
3BK+4rjZQAQn0RF7ZVPntjY=
=KTay
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to