Fetching Outlook Contacts with Python

一世执手 提交于 2020-01-20 06:12:08

问题


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.


回答1:


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")


来源:https://stackoverflow.com/questions/11537808/fetching-outlook-contacts-with-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!