Matthew, thanks, this is a big help. I had played around with initialize but it didn't seem to be working for me; the problem was that I was trying to use mime::parsepart instead of mime::getproperty (the Sloanspace version of mime.tcl is different from, and appears to be newer than, the one in the official TclMime distribution, and has extra functions).
Unfortunately, using your code I'm getting the same result as I was getting with my tests - it still treats the whole thing as plain text. My test message body was captured from within the proc that handles incoming e-mail so it "should" be an accurate representation of what I need to handle. Here is my test script:
ReturnHeaders
set r_dir [acs_root_dir]
source $r_dir/tcl/base64.tcl
source $r_dir/tcl/mime.tcl
package require mime
set body "
> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--B_3138013439_31893367
Content-type: text/plain; charset=\"US-ASCII\"
Content-transfer-encoding: 7bit
Ok, this should be a real HTML message.
On 6/9/03 1:22 PM, \"system.mit.edu mailer\" <system-40576-450@system.mit.edu>
wrote:
> Forum: testgroup Forum
> Thread: HTML reply testing
> Author: Janine Sisk (jsisk@mit.edu)
>
> This is a message
--B_3138013439_31893367
Content-type: text/html; charset=\"US-ASCII\"
Content-transfer-encoding: quoted-printable
<HTML>
<HEAD>
<TITLE>Re: HTML reply testing</TITLE>
</HEAD>
<BODY>
<FONT FACE=3D\"Verdana\">Ok, <B>this</B> should be a <I>real</I> HTML message.<=
BR>
<BR>
On 6/9/03 1:22 PM, "system.mit.edu mailer" <system-40576-450@system.mit.edu> wrote:<BR>
<BR>
<FONT COLOR=3D\"#0000FF\">> Forum: testgroup Forum<BR>
> Thread: HTML reply testing<BR>
> Author: Janine Sisk (jsisk@mit.edu)<BR>
> <BR>
> This is a message<BR>
</FONT></FONT>
</BODY>
</HTML>
--B_3138013439_31893367--
"
set mime [mime::initialize -string $body]
set content [mime::getproperty $mime content]
if { [string first "multipart" $content] != -1 } {
set parts [mime::getproperty $mime parts]
} else {
set parts [list $mime]
}
foreach part $parts {
switch [mime::getproperty $part content] {
"text/plain" {
set plain [mime::getbody $part]
}
"text/html" {
set html [mime::getbody $part]
}
}
}
ns_write "
plain: |$plain|
"
(I left out $html because it's not being set)
The output of this is
plain: | > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3138013439_31893367 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Ok, this should be a real HTML message. On 6/9/03 1:22 PM, "system.mit.edu mailer" wrote: > Forum: testgroup Forum > Thread: HTML reply testing > Author: Janine Sisk (jsisk@mit.edu) > > This is a message --B_3138013439_31893367 Content-type: text/html; charset="US-ASCII" Content-transfer-encoding: quoted-printable Ok, this should be a real HTML message.<= BR>
On 6/9/03 1:22 PM, "system.mit.edu mailer" <system-40576-450@system.mit.edu> wrote:
> Forum: testgroup Forum
> Thread: HTML reply testing
> Author: Janine Sisk (jsisk@mit.edu)
>
> This is a message
--B_3138013439_31893367-- |
I will keep looking at this as well, but if you can spot my error please let me know what it is! Thanks.