Scott,

This was not possible with the current code, because we need to handle binary attachments in a special way. The good news is that we were going to fix this soon, in part to make it possible to send dynamically generated PDF files as attachement.

I checked in a small change that allows this to work, if you want to give it a try. This is not necessarily the final code though.

I also attach an XPL file making use of this funtionality. The new thing is that if you set a content-type on a part which is not "text/*", the content of the part must be Base64-encoded data. Here, I just generate such data with the URL generator from a file on disk.

The result is that an email with an attached JPEG images is sent.

-Erik

Saverance, Kenyon Scott wrote:
Is it possible to construct an email message with a binary attachment
(specifically an Excel file) in the email processor? If so, anyone have any
pointers on how to do it? I would guess there's a way to encode the binary
stream and specify the MIME-type, but I'm not familiar with how to construct
MIME messages. Any pointers/references appreciated. Thanks.

- Scott Saverance
  [EMAIL PROTECTED]
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline";
          xmlns:oxf="http://www.orbeon.com/oxf/processors";>

    <p:processor name="oxf:url-generator">
        <p:input name="config">
            <config>
                <url>oxf:/my-image.jpg</url>
                <content-type>application/octet-stream</content-type>
            </config>
        </p:input>
        <p:output name="data" id="file" debug="file"/>
    </p:processor>

    <p:processor name="oxf:xslt">
        <p:input name="data" href="#file"/>
        <p:input name="config">
            <message xsl:version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
                <smtp-host>your.email.host</smtp-host>
                <from>
                    <email>[EMAIL PROTECTED]</email>
                    <name>Erik Bruchez</name>
                </from>
                <to>
                    <email>[EMAIL PROTECTED]</email>
                    <name>Erik Bruchez</name>
                </to>
                <subject>Hello</subject>
                <body>
                    <part name="part1" content-type="text/plain">
                        <xsl:text>Hello!</xsl:text>
                    </part>
                    <part name="part2" content-type="image/jpeg"
                            content-disposition="inline; 
filename=&quot;image.jpg&quot;">
                        <xsl:copy-of select="/*/text()"/>
                    </part>
                </body>
            </message>
        </p:input>
        <p:output name="data" id="message"/>
    </p:processor>

    <p:processor name="oxf:email">
        <p:input name="data" href="#message"/>
    </p:processor>

</p:config>

Reply via email to