In this article I will explain with an example, how to read vCard (.VCF) Contact Card file and import its information in ASP.Net using C# and VB.Net.
This article makes use of Thought Project vCard Library for reading vCard in ASP.Net.
 
 
VCF Contact Cards
A vCard file is a standard for electronic business cards. vCards are used for storing and sharing Contact Information such as name, email, phone numbers, address, etc. in Cell Phones, Email clients, etc.
Read and Import vCard (.VCF) file information using C# and VB.Net
 
 
Downloading Thought Project vCard package
You will need to install the Thought Project vCard package using the following command.
Install-Package Thought.vCards -Version 1.0.9
 
 
HTML Markup
The following HTML Markup consists of an Image and some Label controls for displaying the imported information from the vCard file.
<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td rowspan="10" valign="top">
            <asp:Image ID="imgPhoto" runat="server" />
        </td>
    </tr>
    <tr>
        <td style=" width: 100px">Name:</td>
        <td><asp:Label ID="lblName" runat="server" /></td>
    </tr>
    <tr>
        <td style="width: 100px">Company Name:</td>
        <td><asp:Label ID="lblOrganization" runat="server" /></td>
    </tr>
    <tr>
        <td style="width: 100px">Title (Position):</td>
        <td><asp:Label ID="lblTitle" runat="server" /></td>
    </tr>
    <tr>
        <td>Mobile Number:</td>
        <td><asp:Label ID="lblMobileNumber" runat="server" /></td>
    </tr>
    <tr>
        <td>Home Number:</td>
        <td><asp:Label ID="lblHomeNumber" runat="server" /></td>
    </tr>
    <tr>
        <td>Work Number:</td>
        <td><asp:Label ID="lblWorkNumber" runat="server" /></td>
    </tr>
    <tr>
        <td>Email Address:
        </td>
        <td><asp:Label ID="lblEmailAddress" runat="server" /></td>
    </tr>
    <tr>
        <td>Website:</td>
        <td><asp:Label ID="lblWebsite" runat="server" /></td>
    </tr>
</table>
 
 
Namespaces
You will need to import the following namespace.
C#
using Thought.vCards;
 
VB.Net
Imports Thought.vCards
 
 
Reading vCard (.VCF) file information in ASP.Net
Inside the Page Load event handler, the vCard file is read into a vCard object.
Once the vCard object is populated, the information such as Name, Organization, Phone Numbers, Email Addresses, Websites and Photo of the contact are retrieved and set in the respective controls.
C#
protected void Page_Load(object sender, EventArgs e)
{
    //Read the vCard file into a vCard object.
    vCard card = new vCard(Server.MapPath("~/vCards/Mudassar Khan.vcf"));
 
    //Read Name.
    lblName.Text = card.FormattedName;
 
    //Read Organization.
    lblOrganization.Text = card.Organization;
 
    //Read Title.
    lblTitle.Text = card.Title;
 
    //Read Cell Phone Number.
    if (card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular) != null)
    {
        lblMobileNumber.Text = card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber;
    }
 
    //Read Home Number.
    if (card.Phones.GetFirstChoice(vCardPhoneTypes.Home) != null)
    {
        lblHomeNumber.Text = card.Phones.GetFirstChoice(vCardPhoneTypes.Home).FullNumber;
    }
 
    //Read Work Number.
    if (card.Phones.GetFirstChoice(vCardPhoneTypes.Work) != null)
    {
        lblWorkNumber.Text = card.Phones.GetFirstChoice(vCardPhoneTypes.Work).FullNumber;
    }
 
    //Read Email Address.
    if (card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet) != null)
    {
        lblEmailAddress.Text = card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet).Address;
    }
 
    //Read Website URL.
    if (card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal) != null)
    {
        lblWebsite.Text = card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal).Url;
    }
 
    //Read Photo.
    if (card.Photos.Count > 0)
    {
        imgPhoto.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(card.Photos[0].GetBytes());
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    'Read the vCard file into a vCard object.
    Dim card As New vCard(Server.MapPath("~/vCards/Mudassar Khan.vcf"))
 
    'Read Name.
    lblName.Text = card.FormattedName
 
    'Read Organization.
    lblOrganization.Text = card.Organization
 
    'Read Title.
    lblTitle.Text = card.Title
 
    'Read Cell Phone Number.
    If card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular) IsNot Nothing Then
        lblMobileNumber.Text = card.Phones.GetFirstChoice(vCardPhoneTypes.Cellular).FullNumber
    End If
 
    'Read Home Number.
    If card.Phones.GetFirstChoice(vCardPhoneTypes.Home) IsNot Nothing Then
        lblHomeNumber.Text = card.Phones.GetFirstChoice(vCardPhoneTypes.Home).FullNumber
    End If
 
    'Read Work Number.
    If card.Phones.GetFirstChoice(vCardPhoneTypes.Work) IsNot Nothing Then
        lblWorkNumber.Text = card.Phones.GetFirstChoice(vCardPhoneTypes.Work).FullNumber
    End If
 
    'Read Email Address.
    If card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet) IsNot Nothing Then
        lblEmailAddress.Text = card.EmailAddresses.GetFirstChoice(vCardEmailAddressType.Internet).Address
    End If
 
    'Read Website URL.
    If card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal) IsNot Nothing Then
        lblWebsite.Text = card.Websites.GetFirstChoice(vCardWebsiteTypes.Personal).Url
    End If
 
    'Read Photo.
    If card.Photos.Count > 0 Then
        imgPhoto.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(card.Photos(0).GetBytes())
    End If
End Sub
 
 
Screenshot
Read and Import vCard (.VCF) file information using C# and VB.Net
 
 
Demo
 
 
Downloads