Better than that, use a perl module from cpan to parse out your mime attachments. Wish I could recall the one I've used with great success in the past, but I'm away from a computer and snowed in at the moment, so I can't http://search.cpan.org .