Ejemplo n.º 1
0
static StringBuffer formatBodyPart(const BodyPart &part)
{
    StringBuffer ret;    
    LOG.debug("FormatBodyPart START");

    ret = MIMETYPE;
    
    ret += part.getMimeType(); ret += ";";
    if (!part.getFilename()) {
        LOG.debug("It doesn't contains an attachment. It is the body");
        ret +=" "; ret += CT_CHARSET; ret += part.getCharset(); 
    }
    ret += NL;
    
    if( part.getFilename() ) {
        ret += "        "; ret += CT_NAME; ret += "\""; ret += part.getFilename(); ret += "\"\n";
    }
    if( part.getEncoding() ) {
        ret += ENCODING; ret += part.getEncoding(); ret += NL;
    }
    if( part.getFilename() ) {
        if( part.getDisposition() ) {
            ret += DISPOSITION; ret += part.getDisposition(); ret += ";\n";
        }
        else {
            ret += DISPOSITION; ret += "attachment;\n";
        }

        ret += "      "; ret += CD_FILENAME; ret += "\""; ret += part.getFilename();
        ret += "\"\n";
    }
    // End of part headers
    ret += NL;
    // Content
    if( part.getFilename() ) {
        char *content = loadAndConvert(part.getContent(), part.getEncoding());
        ret += content;
        delete [] content;
    }
    else
        ret += part.getContent();

    LOG.debug("FormatBodyPart END");
    return ret;
}