re: howto send html mails using smtplib

Discussion in 'Python' started by Tim Williams, Jun 10, 2005.

  1. Tim Williams

    Tim Williams Guest

    "Philippe C. Martin" <> wrote in message
    news:sD3qe.2270$...
    > I have the following problem:
    > 1) I can use smtplib to send text messages
    > 2) I can generate html
    > 3) I want to email the html and want it to be seen by the email client as
    > html.
    >
    > However, when I receive the message, the email client displays it as text
    > (code hereunder) - I assume it has to do with the MIMEText call but since

    I
    > cannot see any MIMEhtml .....



    I suspect you need one of the following lines.

    msg.replace_header('Content-Type', 'text/html')

    msg.add_header('Content-Type', 'text/html')


    HTH :)

    --

    =================================
    Tim Williams
     
    Tim Williams, Jun 10, 2005
    #1
    1. Advertising

  2. Tim,

    You are most correct, replace_header did the trick.

    Thanks a bunch.


    Philippe



    Tim Williams wrote:

    > "Philippe C. Martin" <> wrote in message
    > news:sD3qe.2270$...
    >> I have the following problem:
    >> 1) I can use smtplib to send text messages
    >> 2) I can generate html
    >> 3) I want to email the html and want it to be seen by the email client as
    >> html.
    >>
    >> However, when I receive the message, the email client displays it as text
    >> (code hereunder) - I assume it has to do with the MIMEText call but since

    > I
    >> cannot see any MIMEhtml .....

    >
    >
    > I suspect you need one of the following lines.
    >
    > msg.replace_header('Content-Type', 'text/html')
    >
    > msg.add_header('Content-Type', 'text/html')
    >
    >
    > HTH :)
    >
     
    Philippe C. Martin, Jun 10, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Duy Nguyen

    send mails from asp.net pages

    Duy Nguyen, Aug 9, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    439
    Duy Nguyen
    Aug 11, 2003
  2. Philippe C. Martin

    howto send html mails using smtplib

    Philippe C. Martin, Jun 9, 2005, in forum: Python
    Replies:
    0
    Views:
    360
    Philippe C. Martin
    Jun 9, 2005
  3. Evan
    Replies:
    3
    Views:
    478
  4. Gabriel Genellina

    Re: smtplib send email by using gmail smtp server

    Gabriel Genellina, May 3, 2009, in forum: Python
    Replies:
    0
    Views:
    453
    Gabriel Genellina
    May 3, 2009
  5. Peter Tellgren
    Replies:
    1
    Views:
    372
    Alex Eiras
    Apr 23, 2009
Loading...

Share This Page