Automate Weekly Email Reports with Python Stop manually compiling weekly reports. Python can gather data and email it automatically. Build the Report Content import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from datetime import datetime def get_weekly_stats (): # Replace with your actual data sources return { " revenue " : 12450 , " new_signups " : 87 , " churn_rate " : 2.1 , " week " : datetime . now (). strftime ( " %Y-W%V " ) } def format_report ( stats ): html = " <html><body> " html += " <h2>Weekly Report - " + stats [ ' week ' ] + " </h2> " html += " <table border= ' 1 ' cellpadding= ' 8 ' > " html += " <tr><td>Revenue</td><td>$ " + str ( stats [ ' revenue ' ]) + " </td></tr> " html += " <tr><td>New Signups</td><td> " + str ( stats [ ' new_signups ' ]) + " </td></tr> " html += " <tr><td>Churn Rate</td><td> " + str ( stats [ '…