Rolf12
Rolf12

Reputation: 771

HTML: text colour in automatic generated email with python

I generated some python code using smtplib to send automatic emails. Everything works but when I send emails the body of the text and html version sometimes changes randomly the colour to purple. Is there way to make sure it is always black (or other colour)? Many thanks!!!

        text = """\
        Dear Dr """ + name + """,
        How are you?
        the budget is ready:
        """
        html = """\
        <html>
          <body>
            <p style="color: black;">Dear Dr """ + name + """,<br>
               How are you?<br>
               <a href="http://www.example.com">xxx</a> 
               has many great info.
            </p>
          </body>
        </html>
        """

        # Turn these into plain/html MIMEText objects
        part1 = MIMEText(text, "plain")
        part2 = MIMEText(html, "html")


        # Add HTML/plain-text parts to MIMEMultipart message
        # The email client will try to render the last part first
        message.attach(part1)
        message.attach(part2)

Upvotes: 2

Views: 1859

Answers (1)

Aidan
Aidan

Reputation: 53

For others with this issue, Gmail groups emails from the same sender together and will highlight lines that are the same from previous emails in the group with a purple color. It is a feature of Gmail, and not a coding error. Delete all previous emails in the group and send it again to see the color change back.

Upvotes: 3

Related Questions