VCF with Xojo?

  1. 8 months ago

    Karen A

    4 Jan 2019 Pre-Release Testers

    I have been asked if I can take an phone list that is in excel and create VCF (Virtual Contact Format) files (?) that can be emailed to everyone on the list so they have all have each other phone numbers automagically on their phones (Android and iPhones)... Too many to hand enter.

    Has anybody done something like this? Is is difficult... what would I have to do?

    I am aware that VCF exists but I know nothing about it.

    Thanks,
    - karen

  2. Dave S

    4 Jan 2019 San Diego, California USA

    what you are talking about is VCard format.... Super simple to create using Xojo.
    years back I did some project, where I did just what you are describing... it actually took data from multiple files and spit out a VCard file that was then loaded into their contacts list.

    The Apple Address book can export data in this format, and it should be simple to reverse engineer it, thats what I did. :)

  3. Jean-Yves P

    4 Jan 2019 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    no need to reverse ...
    https://tools.ietf.org/html/rfc6350

  4. Tim P

    4 Jan 2019 Pre-Release Testers Rochester, NY

    I know one of your concerns is usually cost, but I don't recall if you're a fan of plugins.
    Have you considered how you're going to read the excel file? If it's not CSV, you may need an Excel plugin to handle it. I do like Einhugur's Excel plugins, I just recently used the writer to generate some reports and it was easy and straightforward.

  5. Karen A

    4 Jan 2019 Pre-Release Testers

    @Tim P I know one of your concerns is usually cost, but I don't recall if you're a fan of plugins.
    Have you considered how you're going to read the excel file? If it's not CSV, you may need an Excel plugin to handle it. I do like Einhugur's Excel plugins, I just recently used the writer to generate some reports and it was easy and straightforward.

    I have the Einhugur Plugins but for this the simplest thing is just to save the excel file as Tab delimited text... reading that in is trival... I use that approach often.

    I have considered using Excel Reader but it just does not seem worth the bother given how easy it is to deal with tab delimited text file for simple lists. (I do use Excel Writer however for other things)

    - karen

  6. Karen A

    4 Jan 2019 Pre-Release Testers

    @Dave S what you are talking about is VCard format.... Super simple to create using Xojo.
    years back I did some project, where I did just what you are describing... it actually took data from multiple files and spit out a VCard file that was then loaded into their contacts list.

    So can you just attach the file to an Email and have the list imported into their contact list on their phone when you email it to them. Do the recipients have to do anything specific when they get the Email?

    - Karen

  7. Dave S

    4 Jan 2019 San Diego, California USA
    Edited 8 months ago

    @Karen A Do the recipients have to do anything specific when they get the Email?

    I believe the have to open their Contacts/Address Book app and Import the file...
    They *may* be able to double click it, you'd have to test that I don't recall its been quite a while.

    The app I wrote took it from an SQLite database and exported it.....

    Also.. you don't HAVE to include all the fields specified in the Standard... just those that you have

  8. Ivan T

    4 Jan 2019 Pre-Release Testers
    Edited 8 months ago

    @Tim P I know one of your concerns is usually cost, but I don't recall if you're a fan of plugins.
    Have you considered how you're going to read the excel file? If it's not CSV, you may need an Excel plugin to handle it. I do like Einhugur's Excel plugins, I just recently used the writer to generate some reports and it was easy and straightforward.

    No need for plugins, just Go to excel (Or any compatible app) and do a Save As CSV took les than a minute.

    @Jean-YvesPochez no need to reverse ...
    https://tools.ietf.org/html/rfc6350

    For this kind of proyect there is no need to learn the entire format.

    @Karen A am aware that VCF exists but I know nothing about it.

    Jus grab your phone, go to contacts, select one and edit it with all the fields you need in the vCard. Share the contact as vCard, send it yo your mail. Download it in your computer, open it as a plain text file.

    All you need to do is create text files with the same structure.

  9. Dave S

    4 Jan 2019 San Diego, California USA
    Edited 8 months ago

    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>","\n")
              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)="\n"
                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
    
  10. Tim P

    4 Jan 2019 Pre-Release Testers Rochester, NY

    @Pedro I;Tellez&nbsp;Corella No need for plugins, just Go to excel (Or any compatible app) and do a Save As CSV took les than a minute.

    You entirely missed the point of my post in order to try to correct me on something. You didn't even bother to read the whole post. Please stop acting like this, it's immature and not appreciated.

  11. Maximilian T

    4 Jan 2019 Pre-Release Testers, Xojo Pro Europe, Germany, Berlin

    Has anybody done something like this?

    Yes, by me, see www.excel2vCard.com . It has been created with Xojo and Christian's XL-plugin and got good reviews on the App Store (https://itunes.apple.com/us/app/excel2vcard/id994556965?mt=12 ). It sells very well (at around 10USD for a license, but it is free to try).

  12. 7 months ago

    Hal G

    5 Jan 2019 Pre-Release Testers, Xojo Pro, XDC Speakers CampSoftware.com

    vCards are just text files that have a "vcf" extension. Here's some FileMaker code that I used long ago to export vCards. You just repeat this for each contact that you grab from the Excel file. :)

    the_vCard = "BEGIN:VCARD¶VERSION:2.1¶" ;
    the_vCard = the_vCard & "N:" & the_vname & "¶" ;
    the_vCard = the_vCard & "FN:" & the_vfname & "¶" ;
    the_vCard = the_vCard & "ORG:" & the_vorg & ";¶" ;
    the_vCard = the_vCard & the_Phones ;
    the_vCard = the_vCard & the_Email ;
    the_vCard = the_vCard & the_Addr ;
    the_vCard = the_vCard & If ( IsEmpty ( IsOrganization ) ; "" ; "X-ABShowAs:COMPANY" & "¶" ) ;
    the_vCard = the_vCard & If ( Count ( Contacts.ContactsCategories::_ID ) = 0 ; "" ; "CATEGORIES:" & Substitute ( List ( Contacts.ContactsCategories::CategoryName ) ; "¶" ; "," ) & "¶" ) ;
    the_vCard = the_vCard & "NOTE:" & Filter ( Substitute ( TextWhitespaceTrim ( Notes ) ; [ "¶";"\n"] ; [ ",";"\,"] ; [ ":";"\:"] ; [ ";";"\;"] ) ; the_Filter) & "¶" ; ;
    the_vCard = the_vCard & "END:VCARD¶¶"

    FYI, FileMaker uses & to append strings and ¶ represents a char(13). If you have any questions about any of this just ask...

    More about vCards: https://en.wikipedia.org/wiki/VCard

    I saw that I'm using a very old vCard version, but I bet it still works fine.

    I hope this helps!

  13. Dave S

    5 Jan 2019 San Diego, California USA

    Hal's code uses VCard 2.1, the code example I posted was VCard 3.0 ... not real sure what the specific differences are

  14. Karen A

    5 Jan 2019 Pre-Release Testers Answer

    Thanks all... I have all I need... all I really need for this are the name fields, Organization Email and Cell Phone number so i don't need most of the fields.

    This will be very simple..

    Thanks

    - karen

or Sign Up to reply!