Search code examples
pythonemailoutlookwin32comoffice-automation

How to trigger Python script when sending an Outlook email?


I would like to trigger a Python script when I send an email through Outlook.

So far I have only seen solutions to trigger a Python script when an email is received but not when sending an email.


Solution

  • The ItemSend event of the Outlook Application class is fired for outgoing items, whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program.

    Be aware, Outlook should be opened and connected to your code (a valid Application instance retrieved). The event is not fired when Outlook is not running.