How to create Contacts folder in Python


  • Hi,

    I’m trying to import contacts but I’m unable to create a sub-folder of type contacts. I can create a folder just fine like this:

    store = kopano.user(username).store
    contacts = store.contacts
    contacts.create_folder(new_foldername)
    

    But it is created without a PR_CONTAINER_CLASS_W Property, so Webapp displays it as a mail folder. I tried various ways to set that property, but it all fails.
    For example, this was my most promising idea:

    folder = contacts.get_folder(new_foldername)
    folder.prop(PR_CONTAINER_CLASS_W, True, "IPF.Contact")
    

    But this raises the following error:

    Traceback (most recent call last):
      File "kopano-create-folder.py", line 31, in <module>
        folder.prop(PR_CONTAINER_CLASS_W, True, "IPF.Contact")
      File "/usr/lib/python2.7/dist-packages/kopano/properties.py", line 42, in prop
        proptype=proptype)
      File "/usr/lib/python2.7/dist-packages/kopano/property_.py", line 204, in prop
        return create_prop(self, mapiobj, proptag, value=value, proptype=proptype)
      File "/usr/lib/python2.7/dist-packages/kopano/property_.py", line 169, in create_prop
        elif proptype2 & MV_FLAG:
    TypeError: unsupported operand type(s) for &: 'str' and 'int'
    

    How can i create a contacts folder or change an existing folder to contain contacts?

    Thanks for you help.
    Frank