We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding photo data to VCard


In a try to add photo data to a VCard, I’m getting exception. Can you provide some sample code example for this purpose?


Hi Cornelius

Thank you for writing to us.

Please have a look at the following code sample for your kind reference. I am afraid to share that I was not able to face any exception while executing the sample code using the latest version of Aspose.Email for .NET 3.3.0. Please try it at your end and let us know your feedback.

Sample Code:

VCardContact contact = new VCardContact();
contact.IdentificationInfo = new VCardIdentificationInfo();
contact.IdentificationInfo.FullName = new VCardFullName();
contact.IdentificationInfo.FullName.GivenName = "Jon";
contact.IdentificationInfo.FullName.FamilyName = "Anderson";
contact.IdentificationInfo.DisplayName = "Jon Anderson";
contact.IdentificationInfo.Birthday = new DateTime(1983, 04, 03);
contact.IdentificationInfo.Nickname = "JonA";
contact.IdentificationInfo.Photo = new VCardPhoto();
contact.IdentificationInfo.Photo.PhotoType = VCardPhotoType.JPEG;

using (FileStream fs = File.OpenRead("Jon.jpg"))
    byte[] buffer = new byte[fs.Length];
    fs.Read(buffer, 0, buffer.Length);
    contact.IdentificationInfo.Photo.Data = buffer;

contact.Save("jon.vcf", ContactSaveFormat.VCard);