[Zope-dev] attaching images and wav file to email

Mark Hendricks mdh@mark-hendricks.com
Tue, 14 Jan 2003 11:14:09 -0600


I am trying to attach images and other binary data to an email. The  
text attachment works fine.

(I would like to hide the following label(s) if possible...
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="my.ip.501.473.1042563430.436.4336")

Following the dtml documents is the mail I get using these pages...
I would greatly appreciate any help on this.

I have two Zope dtml documents:

--- Number 1  
------------------------------------------------------------------------ 
-----------------------------------------------------------
<dtml-var standard_html_header>
<p>Please send me info.</p>

  <form action="infoAction" method="post" enctype="multipart/form-data">
    <table>
      <tr><td align=right>name:</td><td><input type="text"  
name="user_name" size="40"></td></tr>
      <tr><td align=right>email:</td><td><input type="text" name="email"  
size="40"></td></tr>
      <tr><td align=right>text:</td><td><input type="text"  
name="some_text" size="40"></td></tr>
      <tr><td align=right>image:</td><td><input type="file"  
name=some_jpeg filename="some_jpeg"></td></tr>
      <tr><td colspan=2 align=center><input type="submit"></td></tr>
    </table>
  </form>

<dtml-var standard_html_footer>
--- End Number 1  
------------------------------------------------------------------------ 
----------------------------------------------------

--- Number 2  
------------------------------------------------------------------------ 
-----------------------------------------------------------
<dtml-var standard_html_header>

<h1>Thanks <dtml-var user_name></h1>
<p>Received the info and will send you a mail
at <dtml-var email> when I get this working.</p>

<dtml-sendmail smtphost="my.smtp.host">
To: me@myhost.com
From: <dtml-var email>
Subject: test3-w-image

<dtml-comment><dtml-var subject></dtml-comment>
<dtml-comment><dtml-var body></dtml-comment>
<dtml-mime type=text/plain encode=7bit>
<dtml-var some_text>

<dtml-boundary type="application/octet-stream" disposition="attachment"  
filename="some_jpeg.getId()" encode="base64">
<dtml-var expr="some_jpeg.read()">
<dtml-var some_jpeg>

</dtml-mime>
</dtml-sendmail>

<dtml-var standard_html_footer>

--- End Number 2  
------------------------------------------------------------------------ 
-----------------------------------------------------------

This is what I get back...

From: me@myhost.com
Date: Tue Jan 14, 2003  10:57:08 AM America/Chicago
To: me@myhost.com
Subject: test3-w-image

Mime-Version: 1.0
Content-Type: multipart/mixed;
     boundary="my.ip.501.473.1042563430.436.4336"


--my.ip.501.473.1042563430.436.4336
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

123


--my ip.501.473.1042563430.436.4336
Content-Type: application/octet-stream
Content-Disposition: attachment;
     filename="some_jpeg.getId()"
Content-Transfer-Encoding: base64

/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAHgAA/ 
+4AIUFkb2JlAGTAAAAAAQMA
EAMCAwYAAAJGAAADFAAABe3/ 
2wCEABALCwsMCxAMDBAXDw0PFxsUEBAUGx8XFxcXFx8eFxoaGhoX
Hh4jJSclIx4vLzMzLy9AQEBAQEBAQEBAQEBAQEABEQ8PERMRFRISFRQRFBEUGhQWFhQaJhoa 
HBoa
JjAjHh4eHiMwKy4nJycuKzU1MDA1NUBAP0BAQEBAQEBAQEBAQP/ 
CABEIAGQAZAMBIgACEQEDEQH/
xACsAAEAAgMBAQAAAAAAAAAAAAAABQYBAgQDBwEBAAMBAAAAAAAAAAAAAAAAAAIDBAEQAAEE 
AQMD
BAMAAAAAAAAAAAMBAgQFBiAwEhARE0AhFBUAIjIRAAIBAgQDBgQEBwAAAAAAAAECAxEEACEx 
EjAi
BUFRYXEyEyCBoRQQwVKykUJicoKSwhIAAQIBCwUAAAAAAAAAAAAAARECABAgMEAhMUFRcRID 
kdEi
MhP/ 
2gAMAwEAAhEDEQAAAPoAAAOSm3WiZ5XXuply0RyADBkAAxSrtUyPvPl7GwAAMQ0vUC09NEsx
K1n2iKZXTfz9LogAAYipbBU97RRMtk1AQ1yh2f6tdttQAAAGKxaK6Rlsr0+dYAAAAFbskGc8 
zU58
mGMgAAADQOXnCUyAAH//2gAIAQIAAQUA6yVKjE991JAVfpmR3GHHgtG/1H// 
2gAIAQMAAQUA6t7d
93g7tpE9GueZXJ6j/ 
9oACAEBAAEFANVpN+vrius3LU2gLSHtTo7JUSpsvrZ2Dk8AdpfdDwmTbipp
5FNbjd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