The missing link is found in the IMAP_FETCHSTRUCTURE();
The structure can tell you how many attachments are coming in and how large is the size of the attachment and how large is the data part of the attachment. Then you can use this information to separate them from each other and then decode them.
Don't forget the BOUNDARY
And if you still don't know what you're doing then read this to how it is encoded:
http://www.phpbuilder.com/columns/kartic20000807.php3
//babak