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 property sets and data transfer object 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 or .msg file.

To save ContactDto use SaveContactModelAsync from EmailApi. This method requires 1 parameter — SaveContactModelRequest, which is a request for this operation.

SaveContactModelRequest has 3 parameters:

  • Format — Contact document format. Enum, available values: VCard, WebDav, Msg.
  • Name — Contact document file name.
  • Rq — Create contact request. This parameter accepts StorageModelRqOfContactDto, to initialize this model you should define 2 parameters: Value — ContacDto object and StorageFolder — StorageFolderLocation 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 EmailApi. This method requires 1 parameter — DownloadFileRequest, which is a request for this operation.

DownloadFileRequest has 3 parameters:

  • Path — File path e.g. “/folder/contact_card”.
  • 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 GetContactModelAsync from EmailApi. This method requires 1 parameter — GetContactModelRequest, which is a request for this operation.

GetContactModelRequest has 4 parameters:

  • Format — Contact document format. Enum, available values: VCard, WebDav, Msg.
  • Name — 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:

todo:image_alt_text

This file should be placed somewhere on the disk, for example at “/tmp/alex.png”. To use our parsing API, we should read the file. We need to convert it to the base64 string and send it to parser using our SDK.

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

To initialize this request define AiBcrBase64Rq object.

AiBcrBase64Rq has 2 parameters:

  • Options — Recognition options. AiBcrOptions has 2 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.
  • Images — Vcard file name in storage.  List of AiBcrBase64Image has 2 parameters:
    • IsSingle — Determines that image contains single VCard or more. Ignored in the current version.
    • Base64Data — Image data in base64.

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 GetContactModelListAsync from EmailApi. This method requires 1 parameter — GetContactModelListRequest, which is a request for this operation.

GetContactModelListRequest has 4 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: