plain text parsing to html (newbie problem)

Lie Ryan lie.1296 at gmail.com
Fri Dec 11 05:33:43 EST 2009


On 12/11/2009 8:43 PM, João wrote:
> On Dec 10, 7:55 pm, Lie Ryan<lie.1... at gmail.com>  wrote:
>>
>> and, is there any reason why you're not using the email and smtplib?http://docs.python.org/library/email-examples.html
>
> Mainly because I was unaware of them :(
>
> I just read about them and I found all the Subject, From, To classes,
> but what about Content-Type?
> I need Content-Type: text/html and charset="utf-8" so that I can pass
> a basic CSS formatting.
> How can I do that? With email.mime.base.MIMEBase?

You can set MIME type and encoding from the MIME constructor 
email.mime.Text.MIMEText("<b>Bold Text</b>", "html", "utf-8")

> I'll have to update that in my code later, as I already got it to work
> and my current RHEL5.3 default
> Python 2.4.3 (#1, Sep 17 2008) install is complaining with
> "ImportError: No module named mime.multipart"

are you importing "import mime" or "import email.mime" or "import 
email.MIMEMultipart"?



More information about the Python-list mailing list