Export
is used to export a contact from a contacts database. The information is exported to a vCard file. This API can be called both in synchronous and asynchronous mode.
The following is an example for using Export
:
Asynchronous
event_id = contacts_handle.call('Export', {'Type': u'Contact','Data': {'DestinationFile': u'c:\\Data\\python\\contactlist.vcf', 'id': unicode(req_id)}}, callback=export_contact)
where, export_contact
is a user defined callback function.
The following table summarizes the specification of Export
:
Interface | IDataSource |
Operation | Exports the selected item from the contacts database specified as VCard. |
Response Model | Asynchronous and synchronous for Third Edition FP2 and Fifth Edition devices. Synchronous for Third Edition and Third Edition FP1 devices. |
Pre-condition | Valid IDataSource interface is loaded. Valid contact store must exist. The specified contact ID, retrieved using GetList , must be available. |
Post-condition | Exports contact to the specified file and creates a file in the specified location. |
Input Parameters
The following table describes input parameter properties:
|
BEGIN:VCARD VERSION:2.1 N:Kent; Clark FN:Clark Kent ORG:Superman Inc. TITLE:Super Man TEL;WORK:VOICE:(111) 556-9898 TEL;HOME;VOICE:(090) 556-6767 ADR;WORK:;;3rd Rock from Sun;Solar System;Milky Way LABEL;WORK;ENCODING=QUOTED-PRINTABLE:3rd Rock from Sun=0D=0ASolar System=0D=0AMilky Way ADR;HOME:;;Krypton LABEL;HOME;ENCODING=QUOTED-PRINTABLE:Krypton EMAIL;PREF;INTERNET:clarkkent@krypton.com REV:2008042T195243Z END:VCARD
Output Parameters
The output is an object, which contains ErrorCode
and an ErrorMessage
if the operation fails.
|
Errors
The following table lists the errors and their values:
|
Error Messages
The following table lists the error messages and their description:
|
Example
The following sample code illustrates how to export contacts to a file in VCard format:
import scriptext import e32 # Using e32.Ao_lock() to make main function wait till callback is hit lock = e32.Ao_lock() # Callback function will be called when the requested service is complete def export_contact(trans_id, event_id, input_params): if event_id != scriptext.EventCompleted: # Check the event status print "Error in retrieving required info" print "Error code is: " + str(input_params["ReturnValue"]["ErrorCode"]) if "ErrorMessage" in input_params["ReturnValue"]: print "Error message:" + input_params["ReturnValue"]["ErrorMessage"] else: print "The contact is exported" lock.signal() # Load contacts module contacts_handle = scriptext.load("Service.Contact", "IDataSource") list_contacts = contacts_handle.call('GetList', {'Type': u'Contact', 'Filter': {'SearchVal': u'Clark'}}) for i in list_contacts: req_id = i['id'] event_id = contacts_handle.call('Export', {'Type': u'Contact', 'Data': {'DestinationFile': u'c:\\Data\\python\\contactlist.vcf', 'id': unicode(req_id)}}, callback=export_contact) print "Waiting for the request to be processed!" lock.wait() print "Request complete!"
See About this document... for information on suggesting changes.