Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@asposecloud/aspose-email-cloud
Advanced tools
This repository contains Aspose.Email Cloud SDK for Node.Js source code. This SDK allows you to work with Aspose.Email Cloud REST APIs in your Node.Js applications quickly and easily, with zero initial cost.
Aspose.Email Cloud home
API Reference
Aspose.Email Cloud is a REST API for creating email applications that work with standard email file formats. This SDK:
The complete source code is available in the GIT repository. Use reference documentation, examples from this document and wiki.
To use this SDK, you need an App SID and an App Key; they can be looked up at Aspose Cloud Dashboard (it requires free registration in Aspose Cloud for this).
You can use it directly in your project via the source code or get a npm package From the command line:
npm install @asposecloud/aspose-email-cloud --save
To use the API, you should create an EmailApi object:
var appKey = "Your App Key";
var appSid = "Your App SID";
var api = new EmailApi(appSid, appKey);
See examples below:
var folder = 'some/folder/on/storage';
var storage = 'First Storage'; //Your storage name
var imageData = fs.readFileSync('some/business/card/image/file/on/disk');
var storageFileName = 'someFileName.png'; //Supports different image formats: PNG, JPEG, BMP, TIFF, GIF, etc.
// Upload business card image to storage
await api.uploadFile(new requests.UploadFileRequest(folder + '/' + storageFileName, imageData, storage));
var outFolder = 'some/other/folder/on/storage'; //Business card recognition results will be saved here
await api.createFolder(new requests.CreateFolderRequest(outFolder, storage));
// Call business card recognition action
var result = await api.aiBcrParseStorage(
new requests.AiBcrParseStorageRequest(new models.AiBcrParseStorageRq(
null,
[new models.AiBcrImageStorageFile( //We can process multiple images in one request
true, //the image contains only one business card (you can upload image with multiple cards on it)
new models.StorageFileLocation(storage, folder, storageFileName))],
new models.StorageFolderLocation(storage, outFolder))));
// Get file name from recognition result
var contactFile = result.body.value[0]; //result.body.value can contain multiple files, if we sent multicard images or multiple images
// You can download the VCard file, which produced by the recognition method ...
var contactBinary = await api.downloadFile(new requests.DownloadFileRequest(
contactFile.folderPath + '/' + contactFile.fileName, storage));
// ... and print it to console
console.log(contactBinary.body.toString());
// Also, you can get VCard object properties’ list using Contact API
var contactProperties = await api.getContactProperties(new requests.GetContactPropertiesRequest(
'vcard', contactFile.fileName, contactFile.folderPath, contactFile.storage));
//All VCard’s properties are available as a list. Complex properties are represented as hierarchical structures.
//Let's print all primitive properties’ values:
contactProperties.body.internalProperties
.filter(property => property.type == 'PrimitiveObject')
.map(property => property as models.PrimitiveObject)
.forEach(property =>
console.log('Property name:' + property.name + ' value:' + property.value));
//Read image from file and convert it to Base64 string
var imageData = fs.readFileSync('some/business/card/image/file/on/disk').toString('base64');
var result = await api.aiBcrParse(new requests.AiBcrParseRequest(
new models.AiBcrBase64Rq(undefined, [new models.AiBcrBase64Image(true, imageData)])));
//Result contains all recognized VCard objects (only the one in our case)
var contactProperties = result.body.value[0];
//VCard object is available as a list of properties, without any external calls:
contactProperties.internalProperties
.filter(property => property.type == 'PrimitiveObject')
.map(property => property as models.PrimitiveObject)
.forEach(property =>
console.log('Property name:' + property.name + ' value:' + property.value));
See examples below:
var result = await api.aiNameGenderize(new requests.AiNameGenderizeRequest('John Cane'));
//the result contains a list of hypothesis about a person's gender.
//all hypothesis include score, so you can use the most scored version, which will be the first in a list:
console.log(result.body.value[0].gender); //prints 'Male'
var result = await api.aiNameFormat(new requests.AiNameFormatRequest(
'Mr. John Michael Cane', undefined, undefined, undefined, undefined, '%t%L%f%m'));
console.log(result.body.name); //prints 'Mr. Cane J. M.'
var first = 'John Michael Cane';
var second = 'Cane J.';
var result = await api.aiNameMatch(new requests.AiNameMatchRequest(
first, second));
console.log(result.body.similarity > 0.5); //prints 'true', names look similar
var result = await api.aiNameExpand(new requests.AiNameExpandRequest(
'Smith Bobby'));
var names = result.body.names
.map(weighted => weighted.name)
.forEach(name => console.log(name)); //prints 'Mr. Smith', 'B. Smith', etc.
var prefix = 'Dav';
var result = await api.aiNameComplete(new requests.AiNameCompleteRequest(
prefix));
var names = result.body.names
.map(weighted => prefix + weighted.name)
.forEach(name => console.log(name)); //prints 'David', 'Dave', 'Davis', etc.
var result = await api.aiNameParseEmailAddress(new requests.AiNameParseEmailAddressRequest(
'john-cane@gmail.com'));
var extractedValues = result.body.value
.map(extracted => extracted.name)
.reduce((accumulator, value) => accumulator.concat(value));
var givenName = extractedValues.find(extracted => extracted.category == 'GivenName');
var surname = extractedValues.find(extracted => extracted.category == 'Surname');
console.log(givenName.value); // 'John'
console.log(surname.value); // 'Cane'
All Aspose.Email Cloud SDKs, helper scripts and templates are licensed under MIT License.
FAQs
Aspose.Email Cloud Node.js SDK
We found that @asposecloud/aspose-email-cloud demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.