Export vCards

by dougalder

Export vCards

The purpose of this script set is to export a standard .vcf or vCard files for importing into Contacts applications. The scripts are designed for easy integration with data tables which contain contact and address information. The export should work on Mac/Windows and iOS. The export can handle a Note field with carriage returns with limitations. The script substitutes all carriage returns out of the fields. Carriage returns in address fields may cause problems with the vCard export.

Download Module


Virtual List Technique

Why use a Virtual List to Export this file?
The reason for using the Virtual List technique is because of UTF-8 text formatting issues. The script step ‘Export Field Contents’ generates a UTF-16 formatted text file, which some Calendar apps don’t see as valid. The ‘Export Records’ step has the option of generating a UTF-8 formatted text file, which Calendar apps accept.

Required Version of FileMaker

Created in FileMaker Pro 13, but could probably run in FM12 (not so much the demo file which has FM 13 specific aspects, but the scripts themselves). There is nothing specific that would not allow this to run in FileMaker Pro 11, if you take the time to recreate the scripts in FM 11.

Required Table

Before Importing the vCard Export script, import (or create) the Virtual_List_Utility data table to your solution.

Virtual_List_Utility table should have two fields:

  1. ID_VL (auto-entry serial number field)
  2. virtual_list – a calculation field – GetValue($$virtual_list; ID_VL)

UUID Field – If you don’t already have a UUID field, add one to your Contacts table using FileMaker 13’s Get(UUID). A UUID will help identify the record when you reimport the same record and have the contents match up. If you are working in earlier versions of FileMaker, there are Custom Functions to create UUIDs (www.briandunning.com). Once you add a UUID field, remember to go back and enter a UUID for every record created before the addition of the UUID field.

Import Scripts

Import the vCard Export scripts to your solution and map your fields to the variables at the top of the script.

Map Your Fields

Once you have the Virtual_List_Utility table in place, copy and paste the Export vCard scripts into your solution and edit the fields in the REQUIRED FIELDS script section.

Copy or Create ‘Export vCard’ Button

Copy or create a button in your solution that calls the vCard Export script.
Place the button on your layout for users to export contact info to other contact applications that support the vCard (.vcf) format.


Test the new module on your own data. See HomeBase Software for more troubleshooting tips if you have problems.

29 responses to “Export vCards”

  1. john renfrew says:

    To get photo to work

    Substitute ( Base64Encode ( Contacts::Photo Container ) ; Char ( 13 ) & Char (10) ; “” )

    • dougalder says:

      Great! Tested and it works great. I knew there would be some smart FileMaker Developer out there with a solution to this issue. The Substitute replaces the ASCII Character for a Return with a Line Feed.
      Line feed CHAR(10)
      Carriage return CHAR(13)
      Thanks for contributing John. I will add this to the file and re-upload it.

  2. john renfrew says:

    This is great Doug..
    Smooth as a baby’s bottom as the saying goes
    Couple of other fields to consider adding

    I include Skype in my contacts as I do a lot that way

    ORG:att.it{ude};database management – this can be multiline


  3. Luc Roels says:

    Thanks for a fine module.
    This makes life so much easier.

    There might be a small error in the “Export vCard – Generate vCard Text – Set REQUIRED FIELDS” script at the end where you define the $body variable:
    you wrote: “If(IsEmpty($Note); “”;”PHOTO;ENCODING=b;TYPE=JPEG:”& $Photo & “¶”)&”
    where it probably should be “If(IsEmpty($Photo); “”;”PHOTO;ENCODING=b;TYPE=JPEG:”& $Photo & “¶”)&”.

    I adapted it slightly by passing the contact UUID to the script and setting the required fields through ExecuteSQL calls.
    This way the module can be used from anywhere within our solution.

    A nice addition would be the export of a QRcode using the 360works Scriptmaster plugin.

    Again, thanks for the effort.


    • dougalder says:

      Thanks for the catch Luc. I have fixed it and re-uploaded the file.

      ExecuteSQL sounds like a good variation. That way you could add the little Export vCard button from any portal that listed a contact. Can you post a sample of your ExecuteSQL code?

      Creating a QR Code that embeds a contact’s information in the QR code is interesting. Can you explain what you are doing with the QR Codes once you have created them?

  4. Luc Roels says:

    This is probably easier to code than to explain.
    We have a basic contacts table and a contacts attributes table, which contains all the extra information (addresses, phone numbers, emails, … basically whatever you’d want).
    This is something Matt Petrowsky presented at ISO FileMaker.

    Each attribute has an item code (for email, phone, etc…), a value, an id, an external id and … .
    We then use a number of small scripts which return the attribute you are looking for. Mostly just plain SQL (SELECT value FROM table WHERE contactid = $id AND type = $type).
    These scripts can be called from anywhere without adding any extra relations as long as you can pass a contactid.
    An example woud be:
    SQL Get contact mainaddress ( contactid ): street, ZIP, city, country
    Set Variable [$result; #AssignScriptResults]
    Ste Variable [$Address|HOME; Substitute (
    If ( IsEmpty( $street ); “”; $street &”;” ) &
    If ( IsEmpty ( $city ); “”; $city & “;” ) &
    If ( IsEmpty ( $country ); “”; $country & “;” ) &
    If ( IsEmpty ( $zip ); “”; $zip )
    ;”¶”; “”)

    The main advantage of this technique is that you can add almost anything to your contacts without the need of adding new fields (great when one is using the separation model).

    The QR code is presented as a graphic in a container, which then can be copied by the user and pasted into a drawing, footer of a letter, etc… (our solutions caters to architects and engineers).



  5. Doug,

    Your vcf file, when generated on a mac, will not be compatibles with windows outlook (yes, I tested the output of your solution to confirm). I discuss the solution in this blog post:


    Darren Burgess

    • dougalder says:

      Thanks Darren.

      My testing was done on Windows 8.1 through Parallels. I don’t own Office/Outlook, so I was just viewing the files in the default file viewer and the vCards seem to open fine there, with the exception of the Notes field not retaining carriage returns properly. Also when I open these Windows ANSI files in TextPad, a Windows text editor, the carriage returns seem to be respected.

      I also tried importing the test contact into Gmail Contacts and it seems to work properly there as well.

      My goal was to avoid the use of plug-ins (even if they are free like the Base Elements plug-in you are using in your approach).

      Based on the suggestion of your article, I have updated the demo file, adding a “Substitute” wrapper to replace FileMaker’s carriage returns with Char(10) when I set the final global variable $$virtual_list, ready for export via the Virtual List:
      Substitute($Header & $Body &$Footer;”¶”; Char (10) )

      It seems to still work in Mac Contacts, Gmail Contacts, Windows 8 file viewer, TextPad etc.

      Any Outlookers out there care to test how these files are now showing up in Outlook?

      A friend tested the import on his Windows Outlook and was successful in importing the vCard now. I think this issue is resolved.

      Thanks for the feedback.

  6. Leo Di Croce says:

    I think it’s great that Doug shared this. Everything works great except for the email address. This field doesn’t export.

    Is it just me, or is this happening to others?

    Any suggestions?


    • dougalder says:

      Hi Leo,
      What are you seeing when you try to export it? What platform are you running? Presumably you copied the scripts into your own solution. Check the REQUIRED FIELDS script to make sure you are calling the right email addresses. Is it possible that these are in a separate data table? In my tests it seems to export email addresses and yours is the first I have heard of this not working.

      • Leo Di Croce says:

        Hi Doug,

        1. All fields except for the Office Email are exported.
        2. I’m running on Mac.
        3. Yes, I did copy scripts to my own solution, but the results are the same using your demo file.

        Hope that helps,

        • Leo Di Croce says:

          What’s brown and sticky? A stick… as in “|” the vertical bar.

          One was missing from the Set Variable $Body line — approx line 26 — in Export vCard – Generate vCard Text – Set REQUIRED FIELDS script.

          $EmailWork should be $Email|Work

  7. Al says:

    Any thoughts on what it would take to add to the script to send a found set of contacts to Outlook, and automatically save and close the contact screen, so I wouldn’t have to export and save the record individually in Outlook?

    • dougalder says:

      In FileMaker it is pretty simple to create a loop that would export a batch of records.

      Go to First Record
      Perform export script (turn off the dialog box script steps first)
      go to record next (exit after last)
      exit loop

      The next step is getting them into Outlook. A quick Google search suggests that perhaps there already is a toll to handle bulk import into Outlook: http://www.electronmedia.in/wp/free-batch-vcard-vcf-import-utility-for-outlook/

      Another approach might be to create a single file with multiple contacts in it. I looked a bit but did not see if this is possible, the way you can with calendar (.ics) files. More research may be required.

  8. Peter says:

    Hi Doug
    Thx for your great code. So far it works very well, except the photo and, that’s very annoying but not your fault, when there’s an adress with 2 “streets” for example, it doesn’t work. In Switzerland, we have sometimes a format like that:
    Name Surname
    Postal Code City
    So how can i manage, that the street and the “Postfach” are shown in the apple adressbook (when you put it straight in the adressbook, you can write firs Street, hit Enter and then you can write “Postfach”. On the iphone you get directly the option with the 2 “streets”.

    • dougalder says:

      Hi Peter,

      I think the way I would approach this is to export a vCard from the Apple address book and open it in a text editor. See how things are done in there and then go back into the FileMaker demo. Look for the script called ‘Export vCard – Set REQUIRED FIELDS’. First try editing the $Address|Work or $Address|Home variables. They both have two lines for addresses, so it might be something in there. If that doesn’t work, then add the second address line as a new variable in the top section. Then include it in the $Body variable.

      Hope that helps.


  9. Peter says:

    Hi Doug
    Thx for the Tipp, i made it and it works now 🙂

  10. MikeW says:

    Its still unresolved for me. The Export file is Windows ANSI and the virtual list is set with Char10 in place of the FmPro line returns

  11. Olly says:

    Hi Doug,

    Hoping you are still supporting this? Very useful technique, but for the life of me I cannot export Birthdays… I have added int the Bday tag, and my date of birth on my record is YYYY-MM-DD
    Any ideas? Many thanks

  12. vMas says:

    any chance of updating the RINGTONE field?

    • dougalder says:

      I am not going to add it, being somewhat on the busy side these days, but should be fairly easy to add for your own solution.

      Here is how: Add another Set Variable step in the ‘Export vCard – Generate vCard Text – Set REQUIRED FIELDS’ script. Then look for the Set Variable $Body step and add it in there in the manner that the other lines are.

      If in doubt where it should go, export a vCard with a ringtone and inspect it with a text editor.

      Good luck.


  13. coco says:

    How can I make this script work with Asian characters?
    All the Japanese, Chinese contacts (names, addresses, etc) do not appear.

  14. Paul says:

    Thanks Still works with FM18. Will look at updating to Vcard 4.0 and send that through to you when done.

Leave a Reply

Your email address will not be published. Required fields are marked *