Решение;
import numpy as np
import pandas as pd
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
data = pd.read_csv("Words.csv")
row1 = data.sample(n=5)
A = [row1]
num = np.array(row1)
head = ['C1', 'C2', 'C3']
row = ['1','2','3','4','5']
df = pd.DataFrame(num, index=row, columns=head)
html = df.to_html()
print(html)
def py_mail(SUBJECT, BODY, TO, FROM):
"""With this function we send out our html email"""
MESSAGE = MIMEMultipart('alternative')
MESSAGE['subject'] = SUBJECT
MESSAGE['To'] = TO
MESSAGE['From'] = FROM
HTML_BODY = MIMEText(BODY, 'html')
MESSAGE.attach(HTML_BODY)
password = "@YourPassword"
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(FROM,password)
server.sendmail(FROM, [TO], MESSAGE.as_string())
server.quit()
if __name__ == "__main__":
"""Executes if the script is run as main script (for testing purposes)"""
email_content = html
TO = 'to@gmail.com'
FROM ='from@gmail.com'
py_mail("Test email subject", email_content, TO, FROM)