def encode(self, extended):
        """
        Encode each sub-message and added the additional I{multipart} fields.
        """
        result = [_getMessageStructure(p).encode(extended) for p in self._getParts()]
        result.append(self.subtype)
        if extended:
            result.extend(self._extended())
        return result

        Encode each sub-message and added the additional I{multipart} fields.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/imap4.py