Accessing Outlook Public Folders

Bob nobody at nowhere.com
Fri Nov 25 09:47:56 EST 2005


Hi,

I'm new to Python and I want to create a script that will import 
contactitems into an Outlook Public Folder.
Therefore I've installed the Python for Windows Extensions.

This way I can access my personal contacts

<code>
import win32com.client

OutlookObj = win32com.client.Dispatch("Outlook.Application")

Nms = OutlookObj.GetNameSpace("MAPI")
# Personal contacts folder
custs = Nms.GetDefaultFolder(10).Items

print custs.count

for i in range(custs.count):
     cust = custs[i]
     print cust.FullName + " -> " + cust.FileAs
</code>


But when I try to access contacts in the public folder 'klanten' with 
this code I get an error.

<code>
import win32com.client

OutlookObj = win32com.client.Dispatch("Outlook.Application")

Nms = OutlookObj.GetNameSpace("MAPI")
# Folder Klanten from public folders
custs = Nms.Folders.Item("Public Folders").Folders.Item("All Public 
Folders").Folders["Klanten"].Items

print custs.count

for i in range(custs.count):
     cust = custs[i]
     print cust.FullName + " -> " + cust.FileAs
</code>

<error>
Traceback (most recent call last):
   File "D:\PythonScripts\tp2outlook.py", line 13, in -toplevel-
     print cust.FullName + " -> " + cust.FileAs
   File "D:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 
489, in __getattr__
     raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: <unknown>.FullName
</error>

Anyone an idea how I can access those contactitems?

Thanks,

Bob



More information about the Python-list mailing list