Here is the code the I used to EXPORT a VCARD… it will not be a plug-n-play for you, but it might give you some ideas. I also have an IMPORT function as well.
CODE IS SUPPLIED AS-IS FOR ILLUSTRATION PURPOSE ONLY
This was written maybe 8-10 years ago?
Public Sub EXPORT_VCARD(record_id As Integer,file_open as boolean=true, file_close as boolean=true,use_list as boolean=false)
Dim SQL As String
Dim rs As RecordSet
Dim x As Integer
Dim y As Integer
Dim flag As Boolean
Dim s As String
Dim v(6) As String
s=""
If file_open Then
Export_File_Create tbl_CONTACTS,record_id,True
End If
//
SQL="SELECT COUNT(*) AS CNT from '"+tbl_contacts+"' WHERE name is NOT NULL"
If record_id>0 Then SQL=SQL+" and id="+Str(record_id)
flag=DB_Select(SQL,rs)
If flag Then
x=rs.field("cnt").IntegerValue
Else
x=0
End If
'
If x>0 Then
//
SQL= _
"SELECT DISTINCT "+_
" name,"+_
" company,"+_
" address,"+_
" city,"+_
" state,"+_
" zip,"+_
" phone,"+_
" cell,"+_
" email," +_
" website,"+_
" birthday,"+_
" anniversary,"+_
" notes" +_
" FROM '"+tbl_contacts+"' WHERE name IS NOT NULL"
If record_id>0 Then SQL=SQL+" and id="+Str(record_id)
SQL=SQL+" ORDER BY name"
flag=DB_Select(SQL,rs)
If flag Then
While Not rs.eof
xml_write "BEGIN:VCARD"
xml_write "VERSION:3.0"
//
s=String_to_VCard_Name(Trim(rs.field("name").StringValue))
If s<>"" Then
xml_write "N:"+s
s=VCard_Name_to_string(s,False)
xml_write "FN:"+s
End If
'
s=Trim(rs.Field("company").StringValue)
If s<>"" Then xml_write "ORG:"+s
'
v(0)=""
v(1)=""
v(2)=Trim(rs.field("address"))
v(3)=Trim(rs.field("city"))
v(4)=Trim(rs.field("state"))
v(5)=Trim(rs.field("zip"))
v(6)=""
xml_write "ADR;type=HOME:"+Join(v,";")
s=Trim(rs.field("phone").StringValue)
If s<>"" Then xml_write "TEL;TYPE=home:"+s
'
s=Trim(rs.field("cell").StringValue)
If s<>"" Then xml_write "TEL;TYPE=cell:"+s
'
s=Trim(rs.field("email").StringValue)
If s<>"" Then xml_write "EMAIL;type=INTERNET;type=HOME:"+s
'
s=Trim(rs.field("website").StringValue)
If s<>"" Then xml_write "URL:"+s
//
s=Trim(rs.field("birthday").StringValue)
If s<>"" Then
s=OUTPUT_DATE(s) ' yyyymmdd
xml_write "BDAY;value=date:"+Left(s,4)+"-"+Mid(s,5,2)+"-"+Right(s,2)
End If
//
s=Trim(rs.field("anniversary").StringValue)
If s<>"" Then
s=OUTPUT_DATE(s) ' yyyymmdd
'xml_write "X-ANNIVERSARY:"+left(s,4)+"-"+mid(s,5,2)+"-"+right(s,2)
xml_write "item1.X-ABDATE:"+Left(s,4)+"-"+Mid(s,5,2)+"-"+Right(s,2)
xml_write "item1.X-ABLabel:_$!<Anniversary>!$_"
End If
'
s=Trim(rs.field("notes").StringValue)
If s<>"" Then
s=ReplaceAll(s,"<br>","\
")
s=ReplaceAll(s,"<b>","")
s=ReplaceAll(s,"<i>","")
s=ReplaceAll(s,"<u>","")
s=ReplaceAll(s,"<p>","")
x=InStr(s,"<#")
While x>0
y=InStr(x,s,">")
s=Left(s,x-1)+Mid(s,y+1)
x=InStr(s,"<#")
Wend
s=Trim(s)
While Right(s,2)="\
"
s=Trim(Left(s,Len(s)-2))
Wend
s=ReplaceAll(s,",","\\,")
s=ReplaceAll(s,":","\\:")
If s<>"" Then xml_write "NOTE:"+s
End If
//
xml_write "END:VCARD"
rs.MoveNext
Wend
End If
//
End If
If file_close Then Export_File_Close True
End Sub
Private Sub XML_Write(s As String)
Dim i As Integer
If XML_Indent>0 and XML_Encrypt_Key="" Then
For i=1 To XML_Indent*3
XML_OutFile.Write " "
Next
End If
if XML_Encrypt_Key<>"" then s=ENcodebase64(rc4(s,XML_Encrypt_Key),0)
XML_OutFile.Write s+EOL
End Sub
Private Sub Export_File_Create(tbl_name as string, rec_id as integer, is_vcard as boolean = false)
Dim s As String
Dim XML_Serial As String
Dim r As New random
XML_Encrypt_Key=""
If is_vcard Then
s=pgm_name+"_contacts.vcf"
Else
s=pgm_name+"_export_"+tbl_name
If rec_id>0 Then s=s+"_R"+Str(rec_id)
s=s+Ext_Export
// Ask if user wants export encrypted
If option_encrypt_exports Then
XML_SERIAL=Str(r.inrange(12345678,99999999))
XML_Encrypt_Key=Get_Password(xml_serial)
End If
End If
XML_OutPath=SpecialFolder.Desktop.child(s)
If XML_OutPath.exists Then XML_OutPath.delete
XML_OutFile=TextOutputStream.Create(XML_OutPath)
XML_indent=0
If Not is_vcard Then
If xml_serial<>"" Then XML_OutFile.Write "SALT:"+encodebase64(rc4(XML_SERIAL,salt))+EOL
XML_Write XML_Header
End If
End Sub