#zmail 要比默认的email 简单点 import zmail from openpyxl import load_workbook stmp=zmail.server('1678210121@qq.com','秘钥') wb=load_workbook('./create_word/批量生成word/工资数据.xlsx') sh=wb.active header='<tr>' for i,row in enumerate(sh.iter_rows()): if i==0: for col in row: header+=f'<td>{col.value}</td>' header+='</tr>' continue else: into='<tr>' for col in row: into+=f'<td>{col.value}</td>' into+='</tr>' name=row[1].value address=row[9].value info={'subject':'2030年12月工资条','from':'人事部','content_html': f'''<h3>您好:{name}:</h3><p>请查收2030年12月工资详情:</p><table border='1'> {header}{into}</table>''','attachments':['./create_word/批量生成word/24_拆分2.pdf']} stmp.send_mail(f'{address}',info) print(f'发送给{name}成功,邮箱地址为:{address}')