0

****我想用红色突出显示行(不同步),以便我的团队可以在看到电子邮件后立即处理不同步问题。有人可以在这里帮忙。**** 这是我的代码

def bibreport():
    finaldatabib = []
    data={}
    if some condition:
        data['SyncStatus'] = "In Sync"
        finaldatabib.append(data)
    else:
        data['SyncStatus'] = "out of Sync"
        finaldatabib.append(data)

    dfbib = pd.DataFrame(finaldatabib)
    dfbib.index.name = "SNO"
    colsbib = ['SyncStatus']
    databib=dfbib
    return databib,colsbib

def sendmail(databib,colsbib):
    email_user = 'xxx@email.com'
    email_send = ['yyy@email.com']
    html = """
<html>
<html>
<head>
<style>
  table, th, td {{ border: 2px solid black; border-collapse: collapse; }}
  th, td {{ padding: 4px; }}
</style>
</head>
<body><p>Dear Team, </p>
<p>Please find the details below.</p>
{table}
<p>Regards,</p>
<p>xx</p>
</body></html>
"""
    html = html.format(table=tabulate(databib, headers=colsbib ,tablefmt="html"))
    msg = MIMEMultipart("alternative", None, [MIMEText(html,'html')])
    msg['From'] = email_user
    msg['To'] = ",".join(email_send)
    msg['Subject'] = 'xxx report '+'  '+str(now.year)+"/"+str(now.month)+"/"+str(now.day)+" "+str(now.hour)+":"+str(now.minute)
    text = msg.as_string()
    server = smtplib.SMTP('smtpserver',25)
    print("sent to ",email_send)
    server.sendmail(email_user,email_send,text)
    server.quit()

发送邮件(databib,colsbib)

4

0 回答 0