[BUG] MailMessage/MIMEDocument parsing doesn't work beyond the first level.

Ken Causey ken at ineffable.com
Fri Apr 26 19:42:29 UTC 2002

I've been trying to parse email messages with more than the simplest of
structures and can't seem to get anywhere.

VM: Linux 3.2-4743 #1 [oss audio, xshm]
Image: 3.2gamma-4843

Consider an example:  Take an email with an attachment, and forward it
as an attachment.  Diagram:

a Email
b   Body
c   Forwarded Email
d     Body of Forwarded Email
e     Attachment

The problem is that no matter what I do, I can't get to the attachment,
part e.  Or for that matter the body of the forwared email, part d.

I can see 2 ways of going about this:

1.  The body of a MailMessage instantiated from the original email
message (MailMessage class>>from:) returns a MIMEDocument whose parts
message returns an Array with 2 elements.  The first element is a
MailMessage whose body is a MIMEDocuement containing the text labelled
as part b above.  The second element is also a MailMessage whose body is
a MIMEDocument includes all of c-e.  However, this MIMEDocument's parts
message returns an empty array.  I'm stopped at node c.

2.  Again, instantiate a MailMessage using MailMessage class>>from: from
the original email, use MailMessage>>makeMultipart and
MailMessage>>parts returns an OrderedCollection instance with 2
elements.  The first element is a MailMessage, again
MailMessage>>makeMultiPart and MailMessage>>parts on it returns an Array
with only one element, it being a MailMessage whose text is part b.  If
you run makeMultipart and parts on this MailMessage, you keep getting
one element Arrays with the same text.  I guess we can consider this a
recursion limit criterion.

Now, take the second element of the two element Array returned by the
first level of makeMultipart/parts.  This is a MailMessage whose text
contains all of c-e.  Recurse with makeMultipart/parts again and we get
an Array with ONLY one element, a matching MailMessage.  Continued
recursion never visits d or e.

I would really appreciate it if someone can point out my
mistake/misunderstanding here.  Otherwise I have to consider the MIME
system to be less than useful.

Ken Causey

More information about the Squeak-dev mailing list