<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def buildMessage(headers, parts):
 """ Builds a message from some headers and MIME parts. """

    message = multipart.MIMEMultipart('alternative')

    for name, value in headers.iteritems():
        name = name.title()
        if name == "From":
            multipart[name] = _encodeAddress(value)
        elif name in ["To", "Cc", "Bcc"]:
            multipart[name] = _encodeAddresses(value)
        else:
            multipart[name] = _encodeHeader(value)

    for partType, part in parts.iteritems():
        mimeText = text.MIMEText(part.encode("utf-8"), partType, "UTF-8")
        message.attach(mimeText.encode())

    return message