Read vCard
Reads a vCard contact from a .vcf file.
Code
using DRIT.Mail.Rfc.VCard;
using var reader = new VCardReader("contact.vcf");
VCard vcard = reader.Read();
Console.WriteLine($"Formatted name: {vcard.FormattedName}");
Console.WriteLine($"Given name: {vcard.Name?.GivenName}");
Console.WriteLine($"Family name: {vcard.Name?.FamilyName}");
Console.WriteLine($"Organization: {vcard.Organization}");
foreach (VCardEmail email in vcard.Emails)
{
Console.WriteLine($"Email ({email.Type}): {email.Address}");
}
foreach (VCardPhoneNumber phone in vcard.PhoneNumbers)
{
Console.WriteLine($"Phone ({phone.Type}): {phone.Number}");
}
Remarks
VCardReader parses vCard data as defined in RFC 6350. Both vCard 3.0 and
4.0 are supported.