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~1ManojLOCALS~1Tempgen_py2.70062FFF-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 don't understand why it's throwing the error, as I do have a profile named Outlook
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…