Menu

1 / 2

I Automated My Business Emails with Python — Here's the Exact Code

DEV Community·Brad·6 months ago
#854e5Sv0
#python#automation#business#email#import
Reading 0:00
15s threshold

Running a small business means drowning in repetitive emails. Here's how I automated mine with Python in one afternoon.

The Problem

Every week I was spending 3-4 hours:

Sending follow-up emails to clients who hadn't paid

Sending weekly status reports to 10+ clients

Replying to the same 5 "how do I do X?" questions

Manually forwarding supplier invoices to accounting

The Solution: A Python Email Bot

Setup

import smtplib import imaplib import email from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from datetime import datetime , timedelta import schedule import time

Enter fullscreen mode

Exit fullscreen mode

1. Automated Payment Follow-Up Emails

import sqlite3 from datetime import date , timedelta

def check_overdue_invoices (): conn = sqlite3 . connect ( ' invoices.db ' ) cursor = conn . cursor ()

# Find invoices overdue by 7+ days overdue_date = date . today () - timedelta ( days = 7 ) cursor .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.