An alternative to munpack for rfc822 messages is ripmime http://www.pldaniels.com/ripmime/
It lets you pass it the rfc822 attachment (usually something.eml) and it recursively writes out attachments (and text and html files)