通过 python win32com 检索 Outlook 联系人 [英] Retrieving outlook Contacts via python win32com

查看:92
本文介绍了通过 python win32com 检索 Outlook 联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PythonOutlook 中获取联系人.代码是:

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)

我不明白为什么它会抛出错误,因为我有一个名为 Outlook

I don't understand why it's throwing the error, as I do have a profile named Outlook

推荐答案

您可能没有名为Outlook"的配置文件(除非您创建了一个)

You probably don't have a profile named "Outlook" (Unless you created one)

通常个人资料名称"是顶级文件夹的名称,即您的收件箱"所在.如个人文件夹"

Usually the "Profile Name" is the name given to the top level folder, that your "Inbox" is in. As in "Personal Folders"

这篇关于通过 python win32com 检索 Outlook 联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆