Getting Outlook Contacts with Python

I was given the task of retrieving all contacts from (Microsoft) Outlook using Python. I tried this:

import win32com.client
object = win32com.client.Dispatch("Outlook.Application")
ns = object.GetNamespace("MAPI")
print ns

He gave me the conclusion:

<win32com.gen_py.Microsoft Outlook 12.0 Object Library._NameSpace instance at 0x12528376>

I understand what is nsnow an object, but does it give me access to contacts Outlook? If so, how do I choose contacts?
Thank.

+5
source share
1 answer
import win32com.client
import pywintypes

o = win32com.client.Dispatch("Outlook.Application")
ns = o.GetNamespace("MAPI")
profile = ns.Folders.Item("Profile Name")
contacts = profile.Folders.Item("Contacts")
+4
source

All Articles