How do i add body to 'email.mime.multipart.MIMEMultipart' instance?

Justin Ezequiel justin.mailinglists at gmail.com
Wed Feb 4 04:27:22 EST 2009


On Feb 4, 2:50 pm, srinivasan srinivas <sri_anna... at yahoo.co.in>
wrote:
> Hi,
> Could someone tell me the way to add body content to 'email.mime.multipart.MIMEMultipart' instance?
>
> Thanks,
> Srini

excerpt from one of the modules I use:

def build_body(html, text=''):
    text = text.strip() and text or html2text(html).encode('ascii',
'xmlcharrefreplace')
    body = MIMEMultipart('alternative')
    body.attach(MIMEText(text))
    body.attach(MIMEText(html, 'html'))
    return body

HTH

Justin




More information about the Python-list mailing list