I am given a task to fetch all the contacts from (Microsoft)Outlook using Python. I tried this :
import win32com.client
object = win32com.client.Dispatch("Outlook.Application")
ns = object.GetNamespace("MAPI")
print ns
It gave me the output :
<win32com.gen_py.Microsoft Outlook 12.0 Object Library._NameSpace instance at 0x12528376>
I understand that ns
is now an Object but does it give me access to Outlook
contacts ?
If yes then how should I fetch the contacts ?
Thank You.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With