Receive vCard business card

You can also read how to:

Mail.dll .NET email component makes receiving vCard business cards easy.

IMail object exposes VCards collection that contains all vCard business cards that were found while parsing an email.

You can use both IMAP or POP3 protocol to download email from the server.

Here’s the simple sample showing how to process VCard business cards:

// C#

IMail email = new MailBuilder().CreateFromEml(client.GetMessageByUID(uid));

foreach (VCard vCard in email.VCards)
{

    Console.WriteLine("first name: " + vCard.Name.FirstName);
    Console.WriteLine("last name: " + vCard.Name.LastName);
    Console.WriteLine("full name: " + vCard.FullName);
    
    Console.WriteLine("email: " + vCard.Email);
    Console.WriteLine("work phone: " + vCard.WorkPhone);
    Console.WriteLine("home phone: " + vCard.HomePhone);

    if (vCard.WorkAddress != null)
    {
        Console.WriteLine(vCard.WorkAddress.PostOfficeBox);
        Console.WriteLine(vCard.WorkAddress.ApartmentNumber);
        Console.WriteLine(vCard.WorkAddress.Street);
        Console.WriteLine(vCard.WorkAddress.City);
        Console.WriteLine(vCard.WorkAddress.Region);
        Console.WriteLine(vCard.WorkAddress.PostalCode);
        Console.WriteLine(vCard.WorkAddress.Country);
    }
    if (vCard.HomeAddress != null)
    {
        //...
    }

    foreach (VCardPhone phone in vCard.Phones)
    {
        Console.WriteLine("phone: " + phone.Value);
    }
    foreach (VCardAddress address in vCard.Addresses)
    {
        Console.WriteLine("street: " + address.Street);
    }
    foreach (VCardEmail mail in vCard.Emails)
    {
        Console.WriteLine("email: " + mail.Value);
    }
}
' VB.NET

Dim email As IMail = New MailBuilder().CreateFromEml(client.GetMessageByUID(uid))

For Each vCard As VCard In email.VCards

	Console.WriteLine("first name: " + vCard.Name.FirstName)
	Console.WriteLine("last name: " + vCard.Name.LastName)
	Console.WriteLine("full name: " + vCard.FullName)

	Console.WriteLine("email: " + vCard.Email)
	Console.WriteLine("work phone: " + vCard.WorkPhone)
	Console.WriteLine("home phone: " + vCard.HomePhone)

	If vCard.WorkAddress IsNot Nothing Then
		Console.WriteLine(vCard.WorkAddress.PostOfficeBox)
		Console.WriteLine(vCard.WorkAddress.ApartmentNumber)
		Console.WriteLine(vCard.WorkAddress.Street)
		Console.WriteLine(vCard.WorkAddress.City)
		Console.WriteLine(vCard.WorkAddress.Region)
		Console.WriteLine(vCard.WorkAddress.PostalCode)
		Console.WriteLine(vCard.WorkAddress.Country)
	End If
			'...
	If vCard.HomeAddress IsNot Nothing Then
	End If

	For Each phone As VCardPhone In vCard.Phones
		Console.WriteLine("phone: " + phone.Value)
	Next
	For Each address As VCardAddress In vCard.Addresses
		Console.WriteLine("street: " + address.Street)
	Next
	For Each mail As VCardEmail In vCard.Emails
		Console.WriteLine("email: " + mail.Value)
	Next
Next

You can learn here how to send email with VCard.

Tags:       

Questions?

Consider using our Q&A forum for asking questions.