Automating Outlook with pywin32
Platform note
pywin32pywin32 works on Windows.
It uses COM automation to control Outlook.
Example (send email)
outlook_send.py
# Windows-only
import win32com.client
def send_outlook(to: str, subject: str, body: str):
outlook = win32com.client.Dispatch("Outlook.Application")
mail = outlook.CreateItem(0)
mail.To = to
mail.Subject = subject
mail.Body = body
mail.Send()
# send_outlook("to@example.com", "Hi", "Hello from Outlook")outlook_send.py
# Windows-only
import win32com.client
def send_outlook(to: str, subject: str, body: str):
outlook = win32com.client.Dispatch("Outlook.Application")
mail = outlook.CreateItem(0)
mail.To = to
mail.Subject = subject
mail.Body = body
mail.Send()
# send_outlook("to@example.com", "Hi", "Hello from Outlook")Notes
- COM automation can be blocked by security policies
- prefer SMTP/APIs in server environments
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
