编辑代码

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

smtp_server = 'smtp.example.com'
smtp_port = 587
username = 'your-email@example.com'
password = 'your-password'

message = MIMEMultipart()
message['From'] = username
message['To'] = 'recipient@example.com'
message['Subject'] = 'Office Efficiency Report'

body = 'This is a test email to improve office efficiency.'
message.attach(MIMEText(body,'plain'))

body = 'This is a test email to improve office efficiency.'
message.attach(MIMEText(body,'plain'))

try:
    with smtplib.SMTP(smtp_server,smtp_port) as server:
        server.starttls()
        server.login(username,password)
        server.sendmail(username,message['To'],message.as_string())
        print('Email sent successfully!')
        except Exception as e;
        print(f'Error seding email:{e}')