Retrieving outlook Contacts via python
Question: I am Trying to get Contacts out of `Outlook` using `Python`. The code is :

    
    
    import win32com.client
    import pywintypes
    
    o = win32com.client.Dispatch("Outlook.Application")
    ns = o.GetNamespace("MAPI")
    profile = ns.Folders.Item("Outlook")
    contacts = profile.Folders.Item("Contacts")
    

but its giving error like this:

    
    
    Traceback (most recent call last):
      File "my_pro.py", line 7, in <module>
        profile = ns.Folders.Item("Outlook")
      File "C:\DOCUME~1\Manoj\LOCALS~1\Temp\gen_py\2.7\00062FFF-0000-0000-C000-00000
    0000046x0x9x3\_Folders.py", line 70, in Item
        ret = self._oleobj_.InvokeTypes(81, LCID, 1, (9, 0), ((12, 1),),Index
    pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, u'Microsoft Of
    fice Outlook', u'The operation failed. An object could not be found.', None, 0,
    -2147221233), None)
    

I cant understand why its throwing error as I Do have a profile named
`Outlook`  
Thanks


Answer: Here exists a python recipe to read contacts from outlook. Hope it would be
useful. He is using GetDefaultFolder instead of Folders.Item function.

<http://code.activestate.com/recipes/173216-import-outlook-contacts-using-
win32com/>

