Accessing Outlook Public Folders

Discussion in 'Python' started by Bob, Nov 25, 2005.

  1. Bob

    Bob Guest

    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
    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
    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
     
    Bob, Nov 25, 2005
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.