Click here to Skip to main content
13,199,571 members (62,253 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked
Posted 1 Feb 2006

Working with vCards using the MS CDO for Exchange Library

Rate this:
Please Sign up or sign in to vote.
vCard is a popular format developed to exchange business information. It was developed to easily share your contacts with other people. In this article, I will explain how to get personal infromation from a vCard, edit it, and save the changes in a file.


vCard is a popular format developed to exchange business information. It was developed to easily share your contacts with other people using email clients, internet, or event portable devices and cell phones. A vCard file includes text information about name, home and business addresses, phone numbers, and other things. It can also include your photo or company’s logo.

I am working on a web project where users can upload vCards into a system to export personal information. I searched for any information about working with vCards, in MSDN, and found a link to the CDO.Person object in the Microsoft CDO For Exchange 2000 Library. This library doesn’t present until you install Exchange Server. But I Googled and found codex.dll separately here. I registered it using the regsvr32 utility and added it to my Visual Studio project.

If you take a look at the IPerson Interface description, you can find such properties like FirstName, LastName, Company etc. There is also a method GetVCardStrem which returns the ADO Stream object containing the vCard stream information.

For example, to create a CDO.Person object from a vCard file, use the following code:

CDO.Person person = new CDO.Person();
ADODB.Stream s = person.GetVCardStream();

Now, you can access all the CDO.Person properties to retrieve the personal information:

txtFirstName.Text = person.FirstName;
txtLastName.Text = person.LastName;
txtEmail.Text = person.Email;
txtHomePhone.Text = person.HomePhone;
txtCellPhone.Text = person.MobilePhone;

Also, you can store a CDO.Person object into a vCard file using the SaveToFile method of ADODB.Stream:

ADODB.Stream s = person.GetVCardStream();

The first discomfort of this method is the necessity to register COM on a remote server when you are using this approach for web applications. The second problem is you can not work with included images in a vCard. But this is the easiest way to get the main information about a person's contact information from his vCard when you have the Microsoft CDO For Exchange 2000 Library installed.

I created a Windows application in Visual Studio 2005 using C#, with the example code where you can open a sample vCard file, preview data, change it, and then save it in a file. Before running the project, check whether the Microsoft CDO For Exchange library is registered. If not, download it from here and register cdoex.dll with the regsvr32 utility.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Alexander Kleshchevnikov
Web Developer
Ukraine Ukraine
Alexander is freelance web developer with 4 years experience. He has skills in ASP.NET/MS SQL Server, PHP/MySQL, Ruby On Rails, XHTML, CSS. You can contact with me by Also check my homepage at

You may also be interested in...


Comments and Discussions

Generaldoesn't have Person Pin
msn_issue5-Jun-10 9:53
membermsn_issue5-Jun-10 9:53 
GeneralRe: doesn't have Person Pin
Asthana Pratik18-Jul-10 19:46
memberAsthana Pratik18-Jul-10 19:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 1 Feb 2006
Article Copyright 2006 by Alexander Kleshchevnikov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid