Created
April 20, 2021 14:46
-
-
Save israel-dryer/79dfa1b62e3015d0223e4fc072b7b410 to your computer and use it in GitHub Desktop.
reply to a message using outlook and python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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