import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import schedule import time def send_email(): # Email configuration sender_email = 'your_email@example.com' receiver_email = 'recipient@example.com' password = 'your_email_password' # Create message message = MIMEMultipart() message['From'] = sender_email message['To'] = receiver_email message['Subject'] = 'Daily Report' # Email content (can be read from an external file as well) body = """ Hello, This is your daily report. Regards, Your Name """ message.attach(MIMEText(body, 'plain')) # Connect to SMTP server and send email with smtplib.SMTP('smtp.example.com', 587) as server: server.starttls() server.login(sender_email, password) server.sendmail(sender_email, receiver_email, message.as_string()) print('Email sent successfully.') # Schedule the script to run daily schedule.every().day.at("08:00").do(send_email) # Infinite loop to keep the script running while True: schedule.run_pending() time.sleep(60) # Check every minute