Skip to content

Instantly share code, notes, and snippets.

@israel-dryer
Created April 20, 2021 14:46
Show Gist options
  • Save israel-dryer/79dfa1b62e3015d0223e4fc072b7b410 to your computer and use it in GitHub Desktop.
Save israel-dryer/79dfa1b62e3015d0223e4fc072b7b410 to your computer and use it in GitHub Desktop.
reply to a message using outlook and python
import win32com.client as client
outlook = client.Dispatch('Outlook.Application')
namespace = outlook.GetNameSpace('MAPI')
inbox = namespace.GetDefaultFolder(6)
# search for messages meeting a specific criteria
target_messages = [item for item in inbox.Items if 'product' in item.Subject]
# reply to all messages
for message in target_messages:
reply = message.Reply()
reply.HtmlBody = 'Glad you enjoyed the product.' + reply.HtmlBody
reply.Send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment