vCard, also known as VCF (Virtual Contact File), is a file format standard for electronic business cards. vCards are often attached to e-mail messages, but can be exchanged in other ways. They can contain name and address information, telephone numbers, e-mail addresses, URLs, logos, photographs, and even audio clips.
To access Metadata in a vCard, GroupDocs.Metadata API provides the VCardRootPackage.VCardPackageproperty which contains the information extracted from a file. The following are the steps to access metadata in a vCard:
using(Metadatametadata=newMetadata(Constants.InputVcf)){varroot=metadata.GetRootPackage<VCardRootPackage>();foreach(varvCardinroot.VCardPackage.Cards){if(vCard.IdentificationRecordset.PhotoUriRecords!=null){// Iterate all photos represented by URIsforeach(varphotoUriRecordinvCard.IdentificationRecordset.PhotoUriRecords){// Print the property valueConsole.WriteLine(photoUriRecord.Value);// Print some additional parameters of the propertyConsole.WriteLine(photoUriRecord.ContentType);Console.WriteLine(photoUriRecord.MediaTypeParameter);if(photoUriRecord.TypeParameters!=null){foreach(stringparameterinphotoUriRecord.TypeParameters){Console.WriteLine(parameter);}}Console.WriteLine(photoUriRecord.PrefParameter);}}}}
Filtering vCard properties
The GroupDocs.Metadata API provides the ability to filter vCard properties in order to make finding desired information easier. The code sample below demonstrates hot to use the filtering feature.
publicstaticvoidRun(){using(Metadatametadata=newMetadata(Constants.InputVcf)){varroot=metadata.GetRootPackage<VCardRootPackage>();foreach(varvCardinroot.VCardPackage.Cards){// Print most preferred work phone numbers and work emailsvarfiltered=vCard.FilterWorkTags().FilterPreferred();PrintArray(filtered.CommunicationRecordset.Telephones);PrintArray(filtered.CommunicationRecordset.Emails);}}}privatestaticvoidPrintArray(string[]values){if(values!=null){foreach(stringvalueinvalues){Console.WriteLine(value);}}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.