Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-31-2010, 01:29 AM
Junior Member
 
Posts: 7
Default Import contacts AND tags

Hello,

Great job for this fabulous system! I'm new in that forum.

Is there a way to import contacts from the web client import/export tool, including a field for tags?

Thanks,
--
Versatil
Reply With Quote
  #2 (permalink)  
Old 03-31-2010, 03:19 AM
Moderator
 
Posts: 7,928
Default

Welcome to the forums

From within the web client, under preferences, you can import a csv contact list ?
__________________
Reply With Quote
  #3 (permalink)  
Old 03-31-2010, 03:24 AM
Junior Member
 
Posts: 7
Default

Hello,

Thanks for your answer, but I know that "from within the web client, under preferences, you can import a csv contact list".

Precisely, is there a field for TAGS?

--
Versatil
Reply With Quote
  #4 (permalink)  
Old 03-31-2010, 01:47 PM
Advanced Member
 
Posts: 178
Default

To my knowledge I don't think this is possible. When contacts are exported, tag information is not preserved so I'd be surprised if there was a way to import it.

There is a (rather old - last activity September 2007) request for enhancement for this in Bugzilla:
Bug 13246 – csv file import doesn't preserve categories tags
Reply With Quote
  #5 (permalink)  
Old 04-09-2010, 09:07 AM
Junior Member
 
Posts: 7
Default

Hello there,

Well, importing contacts from the web client import/export tool DON'T include tags.

A solution, the zmmailbox CLI command:
Code:
zimbra@cerise:~$ zmmailbox help contact

  autoComplete(ac)             [opts] {query}
    -v/--verbose                 verbose output

  autoCompleteGal(acg)         [opts] {query}
    -v/--verbose                 verbose output

  createContact(cct)           [opts] [attr1 value1 [attr2 value2...]]
    -f/--folder <arg>            folder-path-or-id
    -T/--tags <arg>              list of tag ids/names
    -i/--ignore                  ignore unknown contact attrs

  deleteContact(dct)           {contact-ids}

  flagContact(fct)             {contact-ids} [0|1*]

  getAllContacts(gact)         [opts] [attr1 [attr2...]]
    -f/--folder <arg>            folder-path-or-id
    -v/--verbose                 verbose output

  getContacts(gct)             [opts] {contact-ids} [attr1 [attr2...]]
    -v/--verbose                 verbose output

  modifyContactAttrs(mcta)     [opts] {contact-id} [attr1 value1 [attr2 value2...]]
    -r/--replace                 replace contact (default is to merge)
    -i/--ignore                  ignore unknown contact attrs

  moveContact(mct)             {contact-ids} {dest-folder-path}

  tagContact(tct)              {contact-ids} {tag-name} [0|1*]
Its possible to pass a file containing all the createContact(cct) sub-commands with the -T option.

What you only have to do is to create this file from the csv you wanted to import with the web client import/export tool. I have used the awk utily to do that job:
Code:
awk 'BEGIN { FS = ";" ; RS = "£" } ; {print "zmmailbox -z -m user@domain.com createContact -T " $24 " company " $1 " lastName " $2 " firstName " $3
" jobTitle " $4 " email " $5 " email2 " $6 " workStreet " $7 " workCity " 
$8 " workPostalCode " $9 " workCountry " $10 " workURL " $11 " workPhone 
" $12 " workFax " $13 " workPhone2 " $14 " homeStreet " $15 " homeCity " 
$16 " homePostalCode " $17 " homeCountry  " $18 " homePhone " $19 " 
homeFax " $20 " mobilePhone " $21 " homeURL " $22 " notes " $23 }' < file-to-import.csv
Some tips:
  • RS = "£": in Zimbra, some fields can use multiple lines (notes, workStreet tec.) so you have to tune awk for use multiple lines records.
  • Some records may not have tags, so the awk output generated commands with -T "". -T "" generate errors. So have to delete that string (with a search/replace function), in the commands file generated by awk before his execution.
  • Don't forget to create the corrects tags in Zimbra before!

--
versatil
Reply With Quote
  #6 (permalink)  
Old 06-21-2010, 10:27 AM
Junior Member
 
Posts: 7
Default

Well I just spent all morning wrestling with this, so I figured I'll post my results here.

First, the above awk magic from versatil looks promising, but I didn't seem to have the same csv file format that he was using. I noticed that if I chose to export to "Outlook contacts", then the resulting CSV file did have the field "CATEGORY". So theoretically just rearranging that awk command could have helped, and I would have done this for a smaller number of lines. I was dealing with hundreds of contacts, with multiple-line notes and other complications.

So. I eventually discovered that the REST down/up-loads *do* actually contain tag information. The problem is that they refer to the tags by id, not by name.

My source/destination servers were the result of zmztozmig, and the actual tags themselves had been created for me on the new server. Same name, different IDs.

On each server, you can see the user's tag list like so

Quote:
zmmailbox -z -m username gat
I found that using a combination of createTag, deleteTag, and renameTag, I was able to make the destination server's tag list have the same IDs as the source server.

Once the tags have the same ID's on source and destination server, the REST file format download and upload resulted in the desired effect: the destination address book now shows each contact as having the same tags it had in the source.

Quote:
curl -u username : password http://server/service/home/username/contacts.tgz

curl -u username : password --upload-file contacts.tgz ttp://server/service/home/username/contacts?fmt=tgz
Reply With Quote
  #7 (permalink)  
Old 12-27-2010, 08:34 AM
Starter Member
 
Posts: 1
Default

Is there any way to do this from the Zimbra Desktop? Or does this have to be done by my server administrator?

Thanks!
Reply With Quote
  #8 (permalink)  
Old 12-27-2010, 08:40 AM
Zimbra Consultant & Moderator
 
Posts: 20,313
Default

Quote:
Originally Posted by JonScrut View Post
Is there any way to do this from the Zimbra Desktop? Or does this have to be done by my server administrator?
If you're talking about the commands in the post above yours then it's for the Zimbra Collaboration Suite and it's not possible to do them for Zimbra Desktop.
__________________
Regards


Bill
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.