'Append the message with MIME content to the root node (as attachment)'

def set_message(self, message, mime_type=u'text/html', as_attachment=0, filename=u'attachment.html'):

    from email.mime.text import MIMEText
    (maintype, subtype) = mime_type.split(u'/')
    part = MIMEText(message, _subtype=subtype)
    if as_attachment:
        part.add_header(u'Content-Disposition', u'attachment', filename=filename)
    self.msg_root.attach(part)
