I am trying to verify if internal email address is valid based upon Outlook Global Address List and found out this approach here The code I am using is as follows:
outlook = win32com.client.gencache.EnsureDispatch('Outlook.Application')
recipient = outlook.Session.CreateRecipient(emailToValidate)
recipient.Resolve()
print recipient.Resolved
However, the issue I ran into is that the value of "recipient.Resolved" seems to return True all the time, even if I tested with invalid address. For example, if I typed random internal email address in Outlook and press "Ctrl+K" to resolve it, I will get the error "We won't be able to deliver this message because email address is no longer valid" but using the code above, the address is resolvable. Does anyone know how I can get exact same results with Outlook?
And I am also thinking to communicate with internal mail server to verify email addresses but do not really want to put my cleartext credentials in the script, does anyone have advice about that? Thanks and any help is appreciated.