http://qs321.pair.com?node_id=11141731


in reply to Re: How to get started with scraping my IMAP emails
in thread How to get started with scraping my IMAP emails

In my (not really elegant, not really recommended) approaches, I recursively descend down the MIME message tree and usually output the Content-Type headers, to get a first view of the mail structure:

sub dump_parts($msg, $level=0) { print " " x $level, $msg->content_type, "\n"; for my $part ($msg->parts) { dump_parts($part, $level+1); } } dump_parts( $entity );

Then, I usually modify dump_parts to actually handle the content types (and other criteria) of the parts I'm interested in.

This discussion has given me the idea that maybe having an SQL, XPath or CSS-like query language for the parts could improve things, but so far, I haven't come up with a good enough concept to implement this.