Maybe i missed something along the way but here is the problem. If a message has html and an attachment then when you try grabbing the body with
imap_fetchbody($mbox, $num, 1);
It retrieve the message body which contains both the plain text and HTML version.
So if the message had 2 parts:
1 - Body
2 - Attachment
Both plain text and attachment are in the first part.
How do you then go about splitting the body up into 2 new parts?
Derek C.