Maybe overkill, but I believe Mail-Box might be useful to you.
In reply to Re: Parsing a mail by b10m in thread Parsing a mail by pcouderc