[Solved] Ex-/Import of a public Adressbook
-
Hi @mykey0815 ,
you could either use https://stash.kopano.io/projects/KSC/repos/core-tools/browse/contacts2csv or roll your own with the power of https://documentation.kopano.io/kopano_python_kopano/
-
The Contacts2Csv working only with Contacts of a user - not with public folders. I try it with the user “system”, but i don´t have access to the public folder Adressbook
I try it with “Public Folders\Intern” and “Public Folders\Adressbuch Intern” and “Public Folders” - but every time came up the “NotFoundError”
-
Hi @MyKey0815 ,
Please try the new version of https://stash.kopano.io/projects/KSC/repos/core-tools/browse/contacts2csv.
We added an option to export from the public store.Regards Robin
-
Thanks for you addition. I have try it but they dont work.
The show only follwing Error:
root@SE69J4H32ZA2:~# python export2.py --public --folder "Intern" --export --delimiter ";" running script for 'Public store' Traceback (most recent call last): File "export2.py", line 237, in <module> main() File "export2.py", line 110, in main contacts = store.folder(options.folder) File "/usr/lib/python2.7/dist-packages/kopano/store.py", line 301, in folder return self.subtree.folder(path, recurse=recurse, create=create) File "/usr/lib/python2.7/dist-packages/kopano/folder.py", line 376, in folder raise NotFoundError("no such folder: '%s'" % path) kopano.errors.NotFoundError: no such folder: 'Intern'
In Outlook the Folder is shown as “Adressbuch Intern”
-
but then you should run
python export2.py --public --folder "Adressbuch Intern" --export --delimiter ";"```
-
YES!!! Now the export is working fine
-
Hello,
I have subfolders. Unfortunately these are not synchronized. Can you do something there? -
You need to add the root folder, so if you subfolder in under the default contacts folder then you need to do
python contact2csv.py --user username --folder "Contacts/subfolder" --export
-
@robing
Hi robin,when i try to run the script I get 2 Errors:
[root@server kopano-python]# python contact2csv.py --public --folder "All_Adressen" --export Traceback (most recent call last): File "contact2csv.py", line 243, in <module> main() File "contact2csv.py", line 109, in main print('running script for \'{}\'').format(user) ValueError: zero length field name in format
what is wrong here?
and, what should I do with the two date values?
PR_WEDDING_ANNIVERSARY and PR_BIRTHDAY need to be converted to Epoch timestamp.
how do I convert them? -
Hi,
is it possible to export categories? When i run the script, everything works well, but the .csv file doesn’t show any categories/labels.Jonas
-
@segro are you running python 2.6 perhaps ?
-
it sounds like I should an other version? kopano is on Centos6 / webapp on Centos7 with php56
[root@mail ~]# python -V
Python 2.6.6
[root@mail ~]# ssh webapp
[root@webapp ~]# python -V
Python 2.7.5
[root@webapp ~]# -
The script is using a .format syntax which is only supported on python 2.7 or higher.
You could fix it yourself though
Replace {} with {0} in the line should do the trick. -
it seems to be a little difficult on centos6.
first I installed python 2.7 from redhatyum --enablerepo=centos-sclo-rh -y install python27 ... [root@mail kopano]# python2.7 contacts2csv.py --user username --export Traceback (most recent call last): File "contacts2csv.py", line 13, in <module> import zarafa as kopano ImportError: No module named zarafa
also I tried python33 from that repo, but :
please install python3-kopano
but there is no python3-kopano package for Centos-6 :-(
Replacing all {} with {0} finaly works, but I have to comment out the two lines with Wedding and birthda (how to solve this?)
export is working with that, but import is still with error:
python contacts2csv.py --public --folder TEST --import test_contacts.csv running script for 'Public store' Traceback (most recent call last): File "contacts2csv.py", line 308, in <module> main() File "contacts2csv.py", line 237, in main new_item.mapiobj.SetProps([SPropValue(getattr(MAPI.Util,headers[num]), value)]) File "/usr/lib/python2.6/site-packages/MAPICore.py", line 289, in SetProps def SetProps(self, *args): return _MAPICore.IMAPIProp_SetProps(self, *args) UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 10: ordinal not in range(128) [root@mail kopano]#``` thanks, Sebastian
-
It seems you have a unicode issue there is a ß somewhere in your csv, I am not sure if value.encode(‘utf-8’) will fix your issue you could give it a try.
-
thank you for the quick response, … where should I put the value.encode in the script?
line 237
new_item.mapiobj.SetProps([SPropValue(getattr(MAPI.Util,headers[num]), value.encode(‘utf-8’))])
but did not fix:File "contacts2csv.py", line 237, in main new_item.mapiobj.SetProps([SPropValue(getattr(MAPI.Util,headers[num]), value.encode('utf-8'))]) AttributeError: 'int' object has no attribute 'encode'
-
Just in case someone stumbles across this old thread:
Adding
reload(sys) sys.setdefaultencoding('utf-8')
right after the
import(sys)
solved the problem for me.
Regards,
Stefan