Quick Start With VCard API

VCard API

Aspose.Email Cloud API supports working with VCard files. You can use our API to read, edit and save VCard files. Also, you can use our Business card recognition API to parse VCard file from image.

The SDKs support two different ways of operating with VCard files using MapiContactDto and ContactDto. This tutorial shows how to use ContactDto.

How to Create Contact File Object and Save It to Storage

ContactDto object contains all contact’s information such as gender, surname, email addresses, phone numbers, etc.

Let’s create a ContactDto object and save it to the Storage as .vcf file.

To save ContactDto use SaveAsync from ContactApi. This method requires 1 parameter — ContactSaveRequest, which is a request for this operation.

ContactSaveRequest has 3 parameters:

  • Format — Contact document format. Enum, available values: VCard, WebDav, Msg.
  • StorageFile — Contact document location on storage. This parameter accepts StorageFileLocation object.
  • Value — ContactDto object.

How to create ContactDto object and save it to the Storage?

How to Download VCard File From Storage

You can find the saved file on Aspose.Cloud Dashboard, or download it using SDK.

To find the contact card file on Storage use DownloadFileAsync from FileApi. This method requires 1 parameter — DownloadFileRequest, which is a request for this operation.

DownloadFileRequest has 3 parameters:

  • Path — File path e.g. “/folder/contact.vcf”.
  • StorageName — Storage name.
  • VersionId [optional] — File version ID to download

How to download VCard file from the Storage?

How to Get VCard File From Storage as ContactDto Object

Let’s get this file from storage as a ContactDto object.

To get a contact card file from Storage as ContactDto use GetAsync from ContactApi. This method requires 1 parameter — ContactGetRequest, which is a request for this operation.

ContactGetRequest has 4 parameters:

  • Format — Contact document format. Enum, available values: VCard, WebDav, Msg.
  • FileName — VCard file name in storage.
  • Folder — Path to the folder in storage.
  • Storage — Storage name.

How to get VCard file from the Storage as a ContactDto object?

You can change model fields and save it again. The file will be rewritten if you don’t change file name and location.

How to Use Business Card Recognition API

Now, let’s use our Business Card Recognition API.

First, we need an image of a business card. Something like this:

alex.png

This file should be placed somewhere on the disk, for example at “/tmp/alex.png”.

To parse an image of a contact card use ParseAsync from AiBcrApi. This method requires 1 parameter — AiBcrParseRequest, which is a request for this operation.

AiBcrParseRequest has 4 parameters:

  • Languages — Comma-separated ISO-639 codes of languages (either 639-1 or 639-3; i.e. “it” or “ita” for Italian); it’s "" by default.
  • Countries — Comma-separated codes of countries.
  • File — Vcard file.
  • IsSingle — Determines that image contains single VCard or more. Ignored in the current version.

How to parse an image of business card to VCard?

How to Get a List of VCard Files From One Folder

You can get a list of VCard files stored in one folder on storage using a single API request. Files will be filtered by an extension (.msg for Msg format and .vcf for VCard) and read to list of ContactDto object. The method supports pagination.

To get a list of VCard files use GetListAsync from ContactApi. This method requires 1 parameter — ContactGetListRequest, which is a request for this operation.

ContactGetListRequest has 5 parameters:

  • Format — Contact document format. Enum, available values: VCard, WebDav, Msg.
  • Folder — Path to the folder in storage.
  • Storage — Storage name.
  • ItemsPerPage — Count of items on page.
  • PageNumber — Page number.

How to get a list of VCard files stored in one folder?

More Tutorials

See more Aspose Email tutorials: