Send vCard business card

You can also read how to:

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

MailBuilder class contains AddVCard method, that can be used to add vCard business card as a attachment to your email.
You can use VCard class to create VCARD business card. It provides easy to use API to add phone, email and address information.

Here’s the simple sample showing how to send email with VCard business card:

// C#

// Create VCard business card

VCard vCard = new VCard();

vCard.FullName = "John Doe";
vCard.Name = new VCardName("John", "Doe");
vCard.Organization = new VCardOrganization("Example");
vCard.Title = "CEO";
vCard.Url = "http://www.example.com";

VCardEmail workEmail = new VCardEmail("john.doe@example.com");
workEmail.MarkWork();
workEmail.MarkPreferred();
vCard.Emails.Add(workEmail);

VCardEmail homeEmail = new VCardEmail("john.doe@gmail.com");
homeEmail.MarkHome();
vCard.Emails.Add(homeEmail);

VCardAddress workAddress = new VCardAddress("", "", "501 E. Middlefield Rd.", "Mountain View", "CA", "94043", "U.S.A.");
workAddress.MarkWork();
vCard.Addresses.Add(workAddress);

VCardAddress homeAddress = new VCardAddress("", "", "6544 Battleford Drive", "Raleigh", "NC", "27613-3502", "U.S.A.");
homeAddress.MarkHome();
vCard.Addresses.Add(homeAddress);

VCardPhone homePhone = new VCardPhone("+1-919-676-9515");
homePhone.MarkHome();
vCard.Phones.Add(homePhone);

VCardPhone workPhone = new VCardPhone();
workPhone.AsUri("tel:+1-919-676-9564");
workPhone.MarkWork();
workPhone.MarkFax();
workPhone.MarkVoice();
vCard.Phones.Add(workPhone);


// Create email message

MailBuilder builder = new MailBuilder();
builder.From.Add(new MailBox("john.doe@example.com"));
builder.To.Add(new MailBox("bob@example.com"));
builder.Text = "Business card";
builder.Text = "Here's my business card.";
builder.AddVCard(vCard);
IMail email = builder.Create();


// Send email message using SMTP protocol

using(Smtp smtp  = new Smtp())
{
    smtp.ConnectSSL("imap.example.com");
    smtp.UseBestLogin("user", "password");
    smtp.SendMessage(email);
    smtp.Close();
}
' VB.NET

' Create VCard business card

Dim vCard As New VCard()

vCard.FullName = "John Doe"
vCard.Name = New VCardName("John", "Doe")
vCard.Organization = New VCardOrganization("Example")
vCard.Title = "CEO"
vCard.Url = "http://www.example.com"

Dim workEmail As New VCardEmail("john.doe@example.com")
workEmail.MarkWork()
workEmail.MarkPreferred()
vCard.Emails.Add(workEmail)

Dim homeEmail As New VCardEmail("john.doe@gmail.com")
homeEmail.MarkHome()
vCard.Emails.Add(homeEmail)

Dim workAddress As New VCardAddress("", "", "501 E. Middlefield Rd.", "Mountain View", "CA", "94043", _
	"U.S.A.")
workAddress.MarkWork()
vCard.Addresses.Add(workAddress)

Dim homeAddress As New VCardAddress("", "", "6544 Battleford Drive", "Raleigh", "NC", "27613-3502", _
	"U.S.A.")
homeAddress.MarkHome()
vCard.Addresses.Add(homeAddress)

Dim homePhone As New VCardPhone("+1-919-676-9515")
homePhone.MarkHome()
vCard.Phones.Add(homePhone)

Dim workPhone As New VCardPhone()
workPhone.AsUri("tel:+1-919-676-9564")
workPhone.MarkWork()
workPhone.MarkFax()
workPhone.MarkVoice()
vCard.Phones.Add(workPhone)


' Create email message

Dim builder As New MailBuilder()
builder.From.Add(New MailBox("john.doe@example.com"))
builder.[To].Add(New MailBox("bob@example.com"))
builder.Text = "Business card"
builder.Text = "Here's my business card."
builder.AddVCard(vCard)
Dim email As IMail = builder.Create()


' Send email message using SMTP protocol

Using smtp As New Smtp()
	smtp.ConnectSSL("imap.example.com")
	smtp.UseBestLogin("user", "password")
	smtp.SendMessage(email)
	smtp.Close()
End Using

Such email can be parsed and VCard extracted.

Tags: , , , ,

Questions?

Consider using our Q&A forum for asking any questions.