phpvcf-vcard

Fax number data ignored in vCard (vcf file)


I am writing a Vcard (vcf file) generator for my client and she wants to include the fax number of the users in the db.

Here is the code:

<?php
header('Content-Type: text/x-vcard');  
$name="richard.lee";
header('Content-Disposition: inline; filename= "'.$name.'.vcf"'); 

$delimitor="\r\n";

echo "BEGIN:VCARD". $delimitor;
echo "N:Lee;Richard;;;". $delimitor;
echo "ADR;TYPE=intl,work,postal,parcel:;;Rm 1234, 1/F., Test Address, Kowloon Tong;Hong Kong". $delimitor;
echo "EMAIL;INTERNET:richard.lee@testtest.org.hk". $delimitor;
echo "ORG:Hong Kong Test Authority". $delimitor;
echo "TEL;WORK:89948800". $delimitor;
echo "TEL;FAX:89948890". $delimitor;
echo "TEL;CELL:52232510". $delimitor;
echo "TITLE:Director - Industry Standards and Practices". $delimitor;
echo "URL;WORK:http://www.testtest.org.hk ". $delimitor;
echo "END:VCARD". $delimitor;

When a user visits the link (the PHP script), the browser will download the vCard file and opens it in client (e.g. Outlook), however, all the data are imported into a contact EXCEPT the fax number.

So, what is the reason that the fax number is NOT included in the Vcard import ? Please kindly advise. Thanks


Solution

  • The generated VCARD works for me, shows the FAX number, and is also validated from online tools. However, it seems like Outlook requires a different syntax: WORK,FAX as Type.

    Try this:

    1. Declare VCARD version (using v.3 in my example)
    echo "VERSION:3.0".$delimitor;
    
    1. Switch TEL syntax to newer type
    echo "TEL;type=WORK:89948800".$delimitor;
    echo "TEL;type=WORK,FAX:89948890".$delimitor;
    echo "TEL;type=CELL:52232510".$delimitor;
    

    Complete snippet:

    echo "BEGIN:VCARD".$delimitor;
    echo "VERSION:3.0".$delimitor;
    echo "N:Lee;Richard;;;".$delimitor;
    echo "ADR;TYPE=intl,work,postal,parcel:;;Rm 1234, 1/F., Test Address, Kowloon Tong;Hong Kong".$delimitor;
    echo "EMAIL;INTERNET:richard.lee@testtest.org.hk".$delimitor;
    echo "ORG:Hong Kong Test Authority".$delimitor;
    echo "TEL;type=WORK:89948800".$delimitor;
    echo "TEL;type=WORK,FAX:89948890".$delimitor;
    echo "TEL;type=CELL:52232510".$delimitor;
    echo "TITLE:Director - Industry Standards and Practices".$delimitor;
    echo "URL;WORK:http://www.testtest.org.hk ".$delimitor;
    echo "END:VCARD".$delimitor;
    

    The fax doesn't show in the preview while you import, but if you open the contact on Outlook, you can see the FAX too:

    enter image description here

    Updated after testing on Outlook