Python Email im HTML-Format mimelib

Ich versuche, zwei in Pandas Python erstellte Datenrahmen als HTML-Format in einer vom Python-Skript gesendeten E-Mail zu senden.

Ich möchte einen Text und die Tabelle schreiben und dies für zwei weitere Datenrahmen wiederholen, aber das Skript kann nicht mehr als einen HTML-Block anhängen. Der Code lautet wie folgt:

import numpy as np
import pandas as pd
import smtplib
import time
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

sender = "[email protected]"
recipients = ['[email protected]']
msg = MIMEMultipart('alternative')
msg['Subject'] = "This a reminder call " + time.strftime("%c")
msg['From'] = sender
msg['To'] = ", ".join(recipients)

text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttps://www.python.org"
html = df[['SYMBOL','ARBITRAGE BASIS %']].to_html()

part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')

msg.attach(part1)
msg.attach(part2)

username = '[email protected]'
password = 'blahblah'
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(username,password)
server.sendmail(sender, recipients, msg.as_string())
server.quit()        
print("Success")

Ich erhalte eine E-Mail mit dem letzten Teil als formatierte HTML-Tabelle im E-Mail-Text. Der Text von Teil 1 wird nicht angezeigt. Was ist los

Antworten auf die Frage(4)

Ihre Antwort auf die Frage