In this developerWorks DataPower forum posting the question was raised how to make DataPower send emails with (binary) attachments.
Technote "Sending HTML data using IBM WebSphere DataPower SOA Appliance SMTP url-open extension function" from June this year
http://www-01.ibm.com/support/docview.wss?uid=swg21291029
is a first step. There we can learn that MIME="true" is necessary to do anything more than sending just a normal text email.
Next looking up InfoCenter for url-open (SMTP URLs) tells us that we have to create the raw MIME message ourselves (as in the technote above).
MIME=true | false
Technote "Sending HTML data using IBM WebSphere DataPower SOA Appliance SMTP url-open extension function" from June this year
http://www-01.ibm.com/support/docview.wss?uid=swg21291029
is a first step. There we can learn that MIME="true" is necessary to do anything more than sending just a normal text email.
Next looking up InfoCenter for url-open (SMTP URLs) tells us that we have to create the raw MIME message ourselves (as in the technote above).
MIME=true | false
-
Indicates whether the message body is already in the Multipurpose Internet Mail Extensions (MIME) format. The
-
message is in MIME format when the message body starts with headers. In this case, set to true. The default is
-
false. When set to true, the entire header segment, which is all of the headers of the e-mail message, is limited to 1 KB.
Stylesheet smtp.xsl (5.1 KB) just demonstrates how to do that.
Even more, it provides function mime:sendBodyWithAttachment() for easily sending an email with attachment.
This function makes use of function mime:split64() for ensuring that the base64 encoded (binary) attachment data has at most 76 characters per line (MIME spec requirement).
The attachment sent with the email is retrieved from my private website via another dp:url-open() GET request, see this slide on getgif.xsl:
Please see these two Webcasts on "Non-XML Data Processing in WebSphere DataPower SOA Appliances Stylesheets" for details on binary data processing:
http://www-01.ibm.com/support/docview.wss?uid=swg27022977
http://www-01.ibm.com/support/docview.wss?uid=swg27022979
http://www-01.ibm.com/support/docview.wss?uid=swg27022979
Using coproc2 to execute smtp.xsl returns "sent".
The email got sent to my private email address.
This screenshot of my webmail client proves that sending the email with attachment really worked:
Last, but not least, I want to use this posting for a graphical experiment.
Since the code listings available in this blog are not as "nice" as those in developerWorks forum I took a screenshot of the
terminal with syntax highlighted listing of smtp.xsl. Since best display in this blog is for pictures of width exactly 400 pixels
terminal with syntax highlighted listing of smtp.xsl. Since best display in this blog is for pictures of width exactly 400 pixels
I had to zoom out a little ... the resulting screenshot is a 400x1770 pixel(!) .gif image.
Good that I have a 24'' monitor in my office and a 1920x1200 graphic card for working in "Left" instead of "Normal" view ... :-)