Win32com library to detect if a particular email ID has automatic replies set in Outlook


i am trying to detect if a particular email ID in Outlook has set Automatic reply and fetch the Automatic reply text.

I have defined the following function for getting the Exchange object for an email ID:

import pythoncom
import win32com.client as win32

def get_outlook_instance():
    # Initialize the COM library

    olApp = win32.Dispatch("Outlook.Application")
    # MAPI stands for "Message Application Programming Interface"
    olNS = olApp.GetNameSpace("MAPI")

    return olApp, olNS

def get_address_object_from_email_id(email_id):
    outlook_application, outlook_namespace = get_outlook_instance()
    address_entry = outlook_namespace.CreateRecipient(email_id)
    return address_entry

email_address = ""
recipient = get_address_object_from_email_id(email_address)

# Resolve the recipient's name to get the corresponding ExchangeUser object
exchange_user = recipient.AddressEntry.GetExchangeUser()

Can someone help me with finding automatic reply status & content?

Think is not a python question, its a microsoft outlook API question.

Suggest you read the API docs for the interface you are using.

1 Like

Since I am using the win32com python module, it is somewhat related to Python automation.
I did try to read the Docs & searched blogs but to no avail.

If someone could guide me, it would be great.

You want to automate a Microsoft application using a Microsoft technology, COM.
Why do you think that the language community is your best source of knowledge?
Hint “Microsoft” seems to be the key here, not python.

You may be luck and find a python user that reads questions here that can help.

Are you sure that you need to use a COM API?

A quick search for “outlook COM API” returns lots of responses that are about the outlook REST API. Is this a office 365 outlook that you want to query?

Yes I do agree with you, that it is mostly Microsoft.

Yes it is a Office 365 outlook.

In that case you need to read up on this Outlook API reference - Outlook Developer | Microsoft Learn
And that is not a windows COM API it uses http.