We have an application which accesses user's outlook account via the following code snippet (see the most upvoted answer): Reading e-mails from Outlook with Python through MAPI
import win32com.client
...
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
It worked fine for several months, alas, a few days ago, it began to fail on all of the organization machines, while returning the following error: AttributeError: 'module' object has no attribute 'CLSIDToClassMap'
The source of the error is: WinPython-32bit-3.4.4.2\\python-3.4.4\\lib\\site-packages\\win32com\\client\\gencache.py
I suspect it's related to a security patch applied to Outlook. We use Office 2010 (Outlook 14.0.7173.500 32-bit)
internet has trace of the same problem dating year 2007 : https://mail.python.org/pipermail/python-win32/2007-August/006147.html .
maybe ask the person
The main reason for this attribute error is because your COM-server has shifted from late-binding (dynamic) to early binding (static).
There are two ways to fix this issue:
Use the dynamic module to force your code to work in a late-bound oriented way. Example use:
"win32com.client.dynamic.Dispatch()" instead of "win32com.client.Dispatch()"
Use camelcase sensitive keywords for the early bound oriented way. Example use:
"excel.Visible()" instead of "excel.VISIBLE()" or "excel.visible()"
Or you can also delete the gen_py folder from temp as it makes win32com run in an early binding way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.