How to Export Contact and Calendar Data

The versit API provides support for exporting contact and calendar data to a stream. For example, suppose you want to make changes to an existing contact or calendar entry, and export the same to an external file store. To do so, again create the appropriate parser objects. That is, CParserVCard and CParserVCal objects to export vCards and/or vCalendars. For more information on importing vCard and vCalendar, refer to How to Import Contact and Calendar Data .

Let us assume that, you want to add a new property to the vCard called EMAIL with the parameters ENCODING and CHARSET , and the property value of . To do so, you need to create objects of CParserProperty , an array of CParserParam to hold parameter information, and CParserPropertyValue to hold the property values.

      // String literals representing the property and its value.

// String literals representing the property parameters and their values.

CParserPropertyValue* value=CParserPropertyValueHBufC::NewL(KEmail); // The property value.

// Array to hold parameters of EMAIL property.
CArrayPtr<CParserParam>* arrayOfParams = new(ELeave)CArrayPtrFlat<CParserParam>(2);

// Parameters with their corresponding values are added to the array.
CParserParam* parserParam1=CParserParam::NewL(KParam1,KValue1);
CParserParam* parserParam2=CParserParam::NewL(KParam2,KValue2);

// Associate the property params and property value with the EMAIL property
CParserProperty* property=CParserProperty::NewL(*value,KPName,arrayOfParams);

// Finally add the EMAIL property to the vCard using the parser object.

// Set the character set as ASCII (7-bit) for transformation.

Note that you should include proper error checks in the above given code before using it for production.

Once you have added the EMAIL property, you can externalize (export) the vCard. This time you have to open the file in write mode to externalize the vCard data.

      TInt err = file.Replace(iFsSession, KVCardFileJIS, EFileWrite) // Replace the file with modified information.
// Check if there is any error reported before exporting the vCard.
if(err == KErrNone)

Same procedure could be followed if you want to modify a vCalendar using the CParserVCal object.