/**
* Print table of message body
* $param The mime structure object
*/
function MsgDisplayBody($struct)
{
    echo '<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">';
    echo '  <tr>';
    echo '    <td class="stdFont">';
    MsgParseBody($struct);
    echo '      <br>';
    echo '    </td>';
    echo '  </tr>';
    echo '</table>';
    MsgDisplayFooter();
}
function MsgParseBody($struct)
{
    global $filelist;
    global $errors;
    $ctype_p = strtolower(trim($struct->ctype_primary));
    $ctype_s = strtolower(trim($struct->ctype_secondary));
    switch ($ctype_p) {
        case "multipart":
            switch ($ctype_s) {
                case "alternative":
                    // Handle multipart/alternative parts
                    $alt_entity = FindMultiAlt($struct->parts);
                    // Ignore if we return false NEEDS WORK
                    if ($alt_entity) {
                        MsgParseBody($alt_entity);
                    }
                    break;
                case "related":
                    // Handle multipart/related parts
                    $rel_entities = FindMultiRel($struct);
                    foreach ($rel_entities as $ent) {
                        MsgParseBody($ent);
                    }
                    break;
                default:
                    // Probably multipart/mixed here
                    // Recursively process nested mime entities
                    if (is_array($struct->parts) || is_object($struct->parts)) {
                        foreach ($struct->parts as $cur_part) {
                            MsgParseBody($cur_part);
                        }
                    } else {
                        $errors['Invalid or Corrupt MIME Detected.'] = true;
                    }
                    break;
            }
            break;
        case "text":
            // Do not display attached text types
            if (property_exists($struct, "d_parameters")) {
                if ($attachment = $struct->d_parameters['filename'] or $attachment = $struct->d_parameters['name']) {
                    array_push($filelist, $attachment);
                    break;
                }
            }
            switch ($ctype_s) {
                // Plain text
                case "plain":
                    MsgBodyPlainText($struct->body);
                    break;
                    // HTML text
                // HTML text
                case "html":
                    MsgBodyHtmlText($struct->body);
                    break;
                    // Text type we do not support
                // Text type we do not support
                default:
                    $errors['Portions of text could not be displayed'] = true;
            }
            break;
        default:
            // Save the listed filename or notify the
            // reader that this mail is not displayed completely
            $attachment = $struct->d_parameters['filename'];
            $attachment ? array_push($filelist, $attachment) : ($errors['Unsupported MIME objects present'] = true);
    }
}