1
votes

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)

2

2 Answers

0
votes

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

0
votes

The main reason for this attribute error is because your COM-server has shifted from late-binding (dynamic) to early binding (static).

  • In Late Binding, whenever a method is called, the object is queried for the method and if it succeeds, then the call can be made.
  • In Early Binding, the information of the object model is determined in advance from type information supplied by the object call. Early binding makes use of MakePy. Also, early binding is case sensitive.

There are two ways to fix this issue:

  1. 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()" 
    
  2. 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.