Forum OpenACS Q&A: Re: Parsing an incoming multi-part e-mail message

Collapse
Posted by Janine Ohmer on
Ah...

If I add a line like so:

Content-Type: multipart/alternative; boundary=\"----=_NextPart_000_005F_01C32E8B.2C7DCE40\"

to the start of my message, Matthew's example code works just fine.  And in looking at a message I sent to myself in Apple Mail, I see that that content type *is* included but it's up higher in the message, in the headers.  So it's missing from my sample message but if I'm parsing a real message I'll have it.  *phew*!

Thanks for the tip, Matthew!

Collapse
Posted by Matthew Walker on
You should be passing in the complete message including headers to mime::initialize. In particular the Content-Type header. By doing this it is also able to work out that a plain text message is just that even when there are no MIME related headers and my code will still work and pass back the plain text.

In terms of the versions of mime.tcl I believe TclMime was merged into tcllib. You can get tcllib from <http://sourceforge.net/projects/tcllib/>. I'd suggest actually using the latest version of mime.tcl from the sourceforge CVS, there's been a few bug fixes recently. It will probably require a couple of lines of editing to work in aolserver/openacs to remove some dependencies (on Trf and something I can't remember), I'll dig these out if you like.