From: Sam Roberts Date: 2004-02-07T04:43:51+09:00 Subject: Re: Email parsing Quoteing rove.monteux@fluid-rock.com, on Sat, Feb 07, 2004 at 04:14:01AM +0900: > Yes, I got till there using the net/pop alright, can retrieve headers > (subject, from, to etc). Im a bit lost now, I request the message.body > as it says on the docs, and it returns me nil, both on multipart or not > messages. Sorry, your on your own now, luckily you have the source! > Follows my snippet (message is the full message retrieved with m.pop), > > # deals with the body > puts m.to_s > if m.multipart?() > m.each_part { |g| > puts g.to_s } I think this should be g.decode(). > else > puts m.decode().to_s And this shouldn't have a .to_s. decode() is just a wrapper around a check that its not multi-part, then looks to see if it's qp or base64 encoded, and decodes if appropriate. No docs on what the parts are, but my bet is that they are a RMail:Message, because that's how MIME works: its recursive. Each of those parts could have parts, too. > end > > end First thing I'd do, though, is this: p m.body if m.body.is_a?(Array) m.body.each do |part| p part end end Just to kinda check out what Message.@body is... The mail message you're looking at DOES have a body, doesn't it? :-) I wrote a library like this in C++, and it was fun, but got mostly abandoned. Lickey isn't really working on this now, he's got a life, it sounded like, last time I exchanged mail with him. I'd like to do some work on rubymail, I've some local changes I've made, and I'd like to add some net/(imap,pop) integration, stuff like that, but there are only so many hours in the day. Canada's pretty progressive, but we still haven't managed to legislate a 26 hour day (or even a 4-day workweek, sadly). Good luck, Sam