`from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib `
`SEND_FROM = 'sender mail-ID'
send_to = 'Receiver Mail Id'
EXPORTERS = {'dataframe.xlsx': export_excel} `
` def send_dataframe(send_to, subject, body, df):
multipart = MIMEMultipart()
multipart['From'] = SEND_FROM
multipart['To'] = send_to
multipart['Subject'] = subject
for filename in EXPORTERS: `
` attachment = MIMEApplication(EXPORTERS[filename](df6))
attachment['Content-Disposition'] = 'attachment; filename="
{}"'.format(filename)
multipart.attach(attachment)
multipart.attach(MIMEText(body, 'html'))
s = smtplib.SMTP('localhost')
s.sendmail(SEND_FROM, send_to, multipart.as_string())
s.quit() `
我正在使用此代码将数据框作为电子邮件附件发送,但未显示任何不发送邮件的错误,也未提出一些更好的解决方案将数据框作为电子邮件附件发送
请帮助。提前感谢