How to create a contact record with address field? | How to create a contact record with address field? |


How to create a contact record with address field?


How to create a contact record with address field?  

I create a record, set the name field, number field, and address field, finally,when I call pim_IContacts_AddRecord() to add this record, I got the error code with value 16,telling that there is invalid items.

#define  EBADITEM             16       // Invalid item

When I do not set the address field , it works well. So I think there is something wrong with my code. My code are listed as follows, would someonetell me what's wrong with it, thanks. (By the way, my bmp version is 5.1.00)

ret = pim_IContacts_CreateRecord(pMe->m_BMP_AddrBook,(pim_IContactsRecord**)&pCurRec);  

/*adding name field*/
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Name/1/Type",L"FIRSTNAME");
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Name/1/Value",pNameTemp);
DBGPRINTF("---set name field ret:%d",ret);

/*adding number field*/
ret = pim_IContactsRecord_SetFieldValue(pCurRec,numberTypeStr, L"CELL");	
ret = pim_IContactsRecord_SetFieldValue(pCurRec,numberValueStr, pNumTemp);	
DBGPRINTF("---set cell number field ret:%d",ret);		

/*adding address field*/
//ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Address/1/Type", pim_EFSDBDevice_AddressType_Generic);
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Address/1/Type", pim_EFSDBDevice_AddressType_None);	
ret = pim_IContactsRecord_SetFieldValue(pCurRec,"Address/1/Value", pNoteTemp); 
DBGPRINTF("---set address field ret:%d",ret);	

ret = pim_IContacts_AddRecord(pMe->m_BMP_AddrBook,pCurRec);