Search code examples
pythonoutlookpywin32win32commapi

I am getting this weird ERROR while executing my code it was working normally 3 days ago


 from win32com.client import Dispatch
 outlook = Dispatch("Outlook.Application").GetNamespace("MAPI")
 root_folder = outlook.Folders.Item(1)

AttributeError: module 'win32com.gen_py.00062FFF-0000-0000-C000-000000000046x0x9x6' has no attribute 'CLSIDToPackageMap'

Hi everyone, I am receiving this error while connecting Python to outlook, It was working normally 3 days ago, but suddenly it returns this error, I don t know why, do you have any idea please?


Solution

  • I finally found the solution to this error, you just need to clear and keep the folder C:\Users<username>\AppData\Local\Temp\gen_py empty and then you try this code:

    from win32com.client import Dispatch
    outlook=win32com.client.dynamic.Dispatch("Outlook.Application").GetNamespace("MAPI")
    my_folder = outlook.Folders.Item(1)