Notes:
-
Problem: Running out of stock affects sales.
-
Benefit: Automatically notifies staff when stock levels are low.
-
Adoption: Can be integrated with an e-commerce system to trigger orders automatically.
Code:
import smtplib
from email.mime.text import MIMEText
def send_inventory_alert(product_name, current_stock):
if current_stock < 10:
subject = f"Low Stock Alert: {product_name}"
body = f"The stock for {product_name} is running low ({current_stock} left). Please reorder."
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = 'your_email@example.com'
msg['To'] = 'inventory_manager@example.com'
server = smtplib.SMTP('smtp.example.com')
server.login('your_email@example.com', 'password')
server.sendmail('your_email@example.com', 'inventory_manager@example.com', msg.as_string())
server.quit()
# Usage
send_inventory_alert('Product A', 5)
No comments:
Post a Comment