From: Chris Hall Date: 2006-09-30T23:54:38+09:00 Subject: Re: wrong content-type when trying to parse emails with Net::IMAP ok, maybe i overexplained... if i look at the RFC822.HEADER, it says Content-type: Multipart/Mixed; boundary=Message-Boundary-22611 however, BODYSTRUCTURE says otherwise #"US-ASCII"}, content_id=nil, description=nil, encoding="7BIT", size=218060, lines=2959, md5=nil, disposition=nil, language=nil, extension=nil> the size and lines correspond to the size of the entire mail. BODYSTRUCTURE should be Net::IMAP::BodyTypeMultipart BODY[1] shows: --Message-Boundary-22611 Content-type: text/plain; charset=US-ASCII Content-description: blah blah blah blah blah blah --Message-Boundary-22611 Content-Type: Application/Octet-stream; name=FOOBAR.ZIP Content-transfer-encoding: BASE64 ...[base64 encoded data]... --Message-Boundary-22611-- if BODYSTRUCTURE were multipart, the above would have been parsed by Net::IMAP into the corresponding parts for me to parse, each part being BodyTypeText and BodyTypeBasic respectively. now, what i would EXPECT, is that the BODYSTRUCTURE corresponds with the header and should be multipart/mixed, which would then allow me to grab the parts described above, but as i have explained this is not the case. I deal with other emails that are structured the same way and the BODYSTRUCTURE does in fact show as multipart/mixed so the only thing i can surmise from this is that Net::IMAP is not interpreting the content-type of the mail correctly and defaults to text/plain us-ascii, as described in the RFC. now whether it's a problem internal to Net::IMAP or perhaps the message itself (it was sent using Pegasus Mail v3.50, a DOS application), i have no way of knowing, and was looking for insight. Chris On 9/29/06, Matt Rose wrote: > On 29-Sep-06, at 4:45 PM, Paul Lutus wrote: > > > > > Sure. In e-mails everything is plain text -- it has to be, in order > > to be > > acceptable to the protocol. Therefore the content encoding is set > > up to > > consist entirely of ASCII characters. It is up to the receiving > > software to > > convert this plain-text form into graphics or whatever the content > > actually > > represents. > > > > What paul means is that the Net::IMAP just returns the text, and > you'll have to parse the MIME attachments from the text that is in > the body > > Just out of curiosity, is there a lib in ruby to do this? > > > -- > > Paul Lutus > > http://www.arachnoid.com > > Matt > >